Skip to main content

Pointer

Struct Pointer 

Source
pub struct Pointer { /* private fields */ }
Expand description

Cell-grid pointer position and per-button state, updated by feeding it every Event you receive.

Tracks all three MouseButton variants independently (unlike Interaction’s higher-level click/drag/focus resolution, which only ever resolves the primary button plus a narrower secondary-click signal – see Sense::SECONDARY_CLICK). Mirrors KeyState’s “feed events in, query state out” shape.

pressed/released/scroll_delta are one-shot: populated only for the frame the underlying event arrived in, then cleared by end_frame. pos/is_down are level state that persists until the next change.

Implementations§

Source§

impl Pointer

Source

pub const fn new() -> Self

No known position, nothing pressed.

Source

pub const fn handle_event(&mut self, event: &Event)

Update from a raw input event; ignores everything but Event::Mouse.

Source

pub const fn end_frame(&mut self)

Clear every button’s one-shot pressed/released and this frame’s scroll_delta. Call once per frame, after drawing.

Source

pub const fn pos(&self) -> Option<Pos>

The pointer’s last known cell-grid position, or None if no mouse event has arrived yet.

Source

pub const fn is_down(&self, button: MouseButton) -> bool

true while button is held down.

Always false for a MouseButton variant this crate doesn’t yet track (see button_slot’s doc comment).

Source

pub const fn pressed(&self, button: MouseButton) -> bool

true for exactly the frame button went down.

Always false for a MouseButton variant this crate doesn’t yet track (see button_slot’s doc comment).

Source

pub const fn released(&self, button: MouseButton) -> bool

true for exactly the frame button went up.

Always false for a MouseButton variant this crate doesn’t yet track (see button_slot’s doc comment).

Source

pub const fn scroll_delta(&self) -> i32

Scroll wheel delta accumulated this frame: positive is down/forward, negative is up/backward. Zero if nothing scrolled.

Trait Implementations§

Source§

impl Clone for Pointer

Source§

fn clone(&self) -> Pointer

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 Pointer

Source§

impl Debug for Pointer

Source§

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

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

impl Default for Pointer

Source§

fn default() -> Pointer

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 = 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.
Source§

impl<C> WithAlpha for C
where C: Copy,

Source§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see AlphaFirst).
Source§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see AlphaLast).