pub struct DragRecognizer { /* private fields */ }Expand description
Drag gesture recognizer (INPUT-00 §5).
Sits upstream of TapRecognizer, consuming raw
PointerDown/PointerMove/PointerUp. A contact that moves at least
the start threshold (Euclidean, compared squared) away from its press
origin becomes a drag: DragStart { x, y, origin_x, origin_y } is
emitted once at the crossing, DragMove { x, y } for every subsequent
move, and DragEnd { x, y } in place of the final PointerUp. While
dragging, the raw move/up stream is consumed — combined with
TapRecognizer::cancel at DragStart, a threshold-crossing contact
can never also produce a PressRelease.
Sub-threshold contacts pass through untouched: taps with finger wander keep their existing debounce path. Non-pointer events always pass through unchanged.
Implementations§
Source§impl DragRecognizer
impl DragRecognizer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a recognizer with the default
DRAG_START_THRESHOLD_PX start threshold.
Sourcepub fn with_threshold(threshold_px: i32) -> Self
pub fn with_threshold(threshold_px: i32) -> Self
Create a recognizer with a custom start threshold in pixels.
A threshold of 0 makes the first PointerMove start the drag.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether a drag is currently in progress (DragStart emitted, no
DragEnd yet).
Sourcepub fn process(&mut self, event: &Event) -> Option<Event>
pub fn process(&mut self, event: &Event) -> Option<Event>
Process a raw input event. Returns the event to pass down the
chain — either a drag event (the raw event was consumed) or the
input itself (pass-through), None never escapes a pointer event
silently.
Only PointerDown, PointerMove, and PointerUp participate;
everything else passes through unchanged.