#[non_exhaustive]pub struct TapEvent {
pub position: Point,
pub button: PointerButton,
pub modifiers: Modifiers,
pub pointer: PointerInfo,
}Expand description
Information about a recognized click-style gesture, passed to the
four tap-family handlers (on_tap, on_double_tap, on_triple_tap,
on_long_press).
The struct is #[non_exhaustive] so future fields (timestamp, click
count for a hypothetical on_n_tap, pressure for stylus events) can
land without breaking existing match patterns.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.position: PointPointer position in widget-local coords, captured at the
finalising event (the Up of the last tap for tap / double-tap /
triple-tap; the held Down for long-press, since long-press
recognises on a tick before any Up).
Which button finalised the gesture. Multi-tap recognizers require every tap in the sequence to use the same button — mixed-button sequences fail rather than spuriously firing.
modifiers: ModifiersModifier keys held at the finalising event. Sourced from
WidgetEvent::PointerUp { modifiers, .. } (or PointerDown for
long-press).
pointer: PointerInfoWhich pointer produced the gesture — the mouse, a numbered finger, a
stylus. A handler reads pointer.kind to tell a finger tap from a
click without consulting the tree.
Implementations§
Source§impl TapEvent
impl TapEvent
Sourcepub fn new(position: Point, button: PointerButton, modifiers: Modifiers) -> Self
pub fn new(position: Point, button: PointerButton, modifiers: Modifiers) -> Self
Construct a TapEvent directly. Useful for tests; widgets receive
&TapEvent from the recognizer pipeline and rarely need to build
one by hand.
Sourcepub fn with_pointer(self, pointer: PointerInfo) -> Self
pub fn with_pointer(self, pointer: PointerInfo) -> Self
The same event attributed to pointer. The recognizers build their
TapEvents this way, from the pointer on the sample that finalised the
gesture.