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
impl Pointer
Sourcepub const fn handle_event(&mut self, event: &Event)
pub const fn handle_event(&mut self, event: &Event)
Update from a raw input event; ignores everything but
Event::Mouse.
Sourcepub const fn end_frame(&mut self)
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.
Sourcepub const fn pos(&self) -> Option<Pos>
pub const fn pos(&self) -> Option<Pos>
The pointer’s last known cell-grid position, or None if no mouse
event has arrived yet.
Sourcepub const fn is_down(&self, button: MouseButton) -> bool
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).
Sourcepub const fn pressed(&self, button: MouseButton) -> bool
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).
Sourcepub const fn released(&self, button: MouseButton) -> bool
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).
Sourcepub const fn scroll_delta(&self) -> i32
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§
impl Copy for Pointer
Auto Trait Implementations§
impl Freeze for Pointer
impl RefUnwindSafe for Pointer
impl Send for Pointer
impl Sync for Pointer
impl Unpin for Pointer
impl UnsafeUnpin for Pointer
impl UnwindSafe for Pointer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).