Add support for scrollwheels (#22762)

Adds support for discrete scroll events, such as those sent by a scroll wheel.

Includes the plumbing to convert, dispatch, and handle these events, as well as
Scrollable support for consuming them.
This commit is contained in:
stuartmorgan
2019-03-11 10:08:12 -07:00
committed by GitHub
parent c78ccb0b5e
commit 5922a40e6a
13 changed files with 832 additions and 397 deletions

View File

@@ -169,6 +169,26 @@ class TestPointer {
delta: delta,
);
}
/// Create a [PointerScrollEvent] (e.g., scroll wheel scroll; not finger-drag
/// scroll) with the given delta.
///
/// By default, the time stamp on the event is [Duration.zero]. You can give a
/// specific time stamp by passing the `timeStamp` argument.
PointerScrollEvent scroll(
Offset scrollDelta, {
Duration timeStamp = Duration.zero,
}) {
assert(scrollDelta != null);
assert(timeStamp != null);
assert(kind != PointerDeviceKind.touch, "Touch pointers can't generate pointer signal events");
return PointerScrollEvent(
timeStamp: timeStamp,
kind: kind,
position: location,
scrollDelta: scrollDelta,
);
}
}
/// Signature for a callback that can dispatch events and returns a future that