Skip to main content

PointerFrame

Struct PointerFrame 

Source
#[non_exhaustive]
pub struct PointerFrame { pub cursor: Option<Vec2>, pub delta: Vec2, pub clicked: bool, pub pressed: bool, pub drag_began: bool, pub drag_started: bool, pub dragging: bool, pub tapped: bool, pub double_tapped: bool, pub long_pressed: bool, pub touch_position: Option<Vec2>, pub contacts: u8, }
Expand description

Pointer and click state resolved for one frame.

Carries the cursor position, the per-frame pointer movement, and click-vs-drag flags that manipulation and picking need. Filled by ViewportInput::resolve from state it already tracks, so consumers no longer hand-roll a click-vs-drag threshold.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§cursor: Option<Vec2>

Cursor position in viewport-local pixels. None when the pointer is outside.

§delta: Vec2

Pointer movement in viewport pixels accumulated this frame.

§clicked: bool

True on the frame the primary button was released as a click: the pointer never got the drag threshold away from where it was pressed.

§pressed: bool

True on the frame the primary button was pressed.

§drag_began: bool

True on the first frame a held primary press has moved the drag threshold or more from where it went down. Fires at most once per press, and a press that fires it never ends as a click.

§drag_started: bool
👎Deprecated:

use pressed, or drag_began for the frame the press becomes a drag

True on the frame the primary button was pressed. Same value as pressed; despite the name, the pointer need not have moved. See drag_began for the frame a press becomes a drag.

§dragging: bool

True while the primary button is held.

§tapped: bool

True on the frame a touch contact lifted without having travelled far enough to be a drag. The touch counterpart of clicked.

A double tap sets this as well, on its second tap: telling the two apart needs a delay that only the application can decide to pay.

§double_tapped: bool

True on the frame a second tap landed soon enough, and close enough, to the one before it.

Needs a clock: only resolves when the frame is begun with ViewportInput::begin_frame_at.

§long_pressed: bool

True on the frame a contact has been down and still long enough to count as a long press. Fires once, while the finger is still down, and suppresses the tap that contact would otherwise have produced when it lifts.

Needs a clock: only resolves when the frame is begun with ViewportInput::begin_frame_at.

§touch_position: Option<Vec2>

Where the last touch event landed, in viewport-local pixels. None until one arrives; it is not cleared when the contact lifts, so a tap can be hit-tested on the frame it is reported.

§contacts: u8

How many touch contacts are down.

Trait Implementations§

Source§

impl Clone for PointerFrame

Source§

fn clone(&self) -> PointerFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PointerFrame

Source§

impl Debug for PointerFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for PointerFrame

Source§

fn default() -> PointerFrame

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.