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
This commit is contained in:
parent
8ddfc80c7f
commit
4e7c052b63
@ -463,6 +463,13 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleNonAllowedPointer(PointerDownEvent event) {
|
||||||
|
if (!_gestureAccepted) {
|
||||||
|
super.handleNonAllowedPointer(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleEvent(PointerEvent event) {
|
void handleEvent(PointerEvent event) {
|
||||||
assert(state != GestureRecognizerState.ready);
|
assert(state != GestureRecognizerState.ready);
|
||||||
|
@ -288,6 +288,29 @@ void main() {
|
|||||||
|
|
||||||
longPress.dispose();
|
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', () {
|
group('long press drag', () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user