long_press.dart 816 Bytes
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'arena.dart';
import 'constants.dart';
7
import 'events.dart';
8 9
import 'pointer_router.dart';
import 'recognizer.dart';
10

11
typedef void GestureLongPressCallback();
12 13 14

class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
  LongPressGestureRecognizer({ PointerRouter router, this.onLongPress })
15
    : super(router: router, deadline: kLongPressTimeout);
16

17
  GestureLongPressCallback onLongPress;
18 19 20 21 22 23

  void didExceedDeadline() {
    resolve(GestureDisposition.accepted);
    onLongPress();
  }

24
  void handlePrimaryPointer(PointerInputEvent event) {
25 26 27 28
    if (event.type == 'pointerup')
      resolve(GestureDisposition.rejected);
  }
}