Unverified Commit 4e7c052b authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fix bug in LongPressGestureRecognizer (#81340)

It was incorrectly resetting state when it received a
non-allowed pointer but had already accepted a gesture.

https://github.com/flutter/flutter/issues/81339
parent 8ddfc80c
......@@ -463,6 +463,13 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
}
}
@override
void handleNonAllowedPointer(PointerDownEvent event) {
if (!_gestureAccepted) {
super.handleNonAllowedPointer(event);
}
}
@override
void handleEvent(PointerEvent event) {
assert(state != GestureRecognizerState.ready);
......
......@@ -288,6 +288,29 @@ void main() {
longPress.dispose();
});
testGesture('non-allowed pointer does not inadvertently reset the recognizer', (GestureTester tester) {
longPress = LongPressGestureRecognizer(kind: PointerDeviceKind.touch)..onLongPress = () {};
// Accept a long-press gesture
longPress.addPointer(down);
tester.closeArena(5);
tester.route(down);
tester.async.elapse(const Duration(milliseconds: 500));
// Add a non-allowed pointer (doesn't match the kind filter)
longPress.addPointer(const PointerDownEvent(
pointer: 101,
kind: PointerDeviceKind.mouse,
position: Offset(10, 10),
));
// Moving the primary pointer should result in a normal event
tester.route(const PointerMoveEvent(
pointer: 5,
position: Offset(15, 15),
));
});
});
group('long press drag', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment