Add buttons to gestures (#30339)

* Callbacks of tap, long press, drag, and double tap GR respond to only primary events.
* Add "secondary" callbacks to tap.
* Recognizers only compete on events if there are any related callbacks.
* Add "kSecondaryButton" constant.
This commit is contained in:
Tong Mu
2019-04-29 10:46:33 -07:00
committed by GitHub
parent c1c15dd702
commit 727e7e829f
14 changed files with 1870 additions and 213 deletions

View File

@@ -22,9 +22,14 @@ class TestPointer {
///
/// Multiple [TestPointer]s created with the same pointer identifier will
/// interfere with each other if they are used in parallel.
TestPointer([this.pointer = 1, this.kind = PointerDeviceKind.touch])
TestPointer([
this.pointer = 1,
this.kind = PointerDeviceKind.touch,
this.buttons = kPrimaryButton,
])
: assert(kind != null),
assert(pointer != null);
assert(pointer != null),
assert(buttons != null);
/// The pointer identifier used for events generated by this object.
///
@@ -35,6 +40,10 @@ class TestPointer {
/// [PointerDeviceKind.touch].
final PointerDeviceKind kind;
/// The kind of buttons to simulate on Down and Move events. Defaults to
/// [kPrimaryButton].
int buttons;
/// Whether the pointer simulated by this object is currently down.
///
/// A pointer is released (goes up) by calling [up] or [cancel].
@@ -81,6 +90,7 @@ class TestPointer {
kind: kind,
pointer: pointer,
position: location,
buttons: buttons,
);
}
@@ -105,6 +115,7 @@ class TestPointer {
pointer: pointer,
position: newLocation,
delta: delta,
buttons: buttons,
);
}