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.