Skip to main content

DragRecognizer

Struct DragRecognizer 

Source
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

Source

pub fn new() -> Self

Create a recognizer with the default DRAG_START_THRESHOLD_PX start threshold.

Source

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.

Source

pub fn is_dragging(&self) -> bool

Whether a drag is currently in progress (DragStart emitted, no DragEnd yet).

Source

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.

Source

pub fn tick(&mut self) -> Option<Event>

Family-shape parity with the other recognizers. The drag state machine has no timers in v1; this always returns None and reserves the seam for long-press-to-drag (INPUT-00 §14).

Trait Implementations§

Source§

impl Default for DragRecognizer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.