eager.dart 1.25 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'arena.dart';
import 'events.dart';
import 'recognizer.dart';

/// A gesture recognizer that eagerly claims victory in all gesture arenas.
///
/// This is typically passed in [AndroidView.gestureRecognizers] in order to immediately dispatch
/// all touch events inside the view bounds to the embedded Android view.
/// See [AndroidView.gestureRecognizers] for more details.
class EagerGestureRecognizer extends OneSequenceGestureRecognizer {
15 16 17
  /// Create an eager gesture recognizer.
  ///
  /// {@macro flutter.gestures.gestureRecognizer.kind}
18
  EagerGestureRecognizer({ PointerDeviceKind kind }) : super(kind: kind);
19

20
  @override
21
  void addAllowedPointer(PointerDownEvent event) {
22
    // We call startTrackingPointer as this is where OneSequenceGestureRecognizer joins the arena.
23
    startTrackingPointer(event.pointer, event.transform);
24 25 26 27 28 29 30 31
    resolve(GestureDisposition.accepted);
    stopTrackingPointer(event.pointer);
  }

  @override
  String get debugDescription => 'eager';

  @override
32
  void didStopTrackingLastPointer(int pointer) { }
33 34

  @override
35
  void handleEvent(PointerEvent event) { }
36
}