#[repr(C)]pub struct MouseState {
pub pointer_device_id: u64,
pub cursor_position: CursorPosition,
pub mouse_cursor_type: OptionMouseCursorType,
pub pointer_source: PointerSource,
pub is_cursor_locked: bool,
pub left_down: bool,
pub right_down: bool,
pub middle_down: bool,
pub other_down: u8,
}Expand description
Mouse position, cursor type, user scroll input, etc.
Fields§
§pointer_device_id: u64Which physical pointing device is driving, or 0 when the platform
does not say. (READONLY)
cursor_position: CursorPositionWhere is the mouse cursor currently? Set to None if the window is not focused.
(READWRITE)
mouse_cursor_type: OptionMouseCursorTypeCurrent mouse cursor type, set to None if the cursor is hidden. (READWRITE)
pointer_source: PointerSourceWhat kind of device is currently driving the pointer. (READONLY)
On MouseState rather than on the event because it is a property of
the DEVICE, not of one motion — an app can ask “is this a trackpad?”
from any callback, not only from inside a pointer handler.
is_cursor_locked: boolIs the mouse cursor locked to the current window (important for applications like games)? (READWRITE)
left_down: boolIs the left mouse button down? (READONLY)
right_down: boolIs the right mouse button down? (READONLY)
middle_down: boolIs the middle mouse button down? (READONLY)
other_down: u8Bitmask of the thumb buttons currently held. (READONLY)
A bitmask rather than two bools because the set is open-ended: a mouse
can report buttons past forward, and the shells already carry them as
MouseButton::Other(n). Bit 0 is back, bit 1 is forward — see
MOUSE_OTHER_MASK_BACK / MOUSE_OTHER_MASK_FORWARD; use
MouseState::back_down and MouseState::forward_down rather than
testing bits by hand.
Implementations§
Source§impl MouseState
impl MouseState
Sourcepub const fn forward_down(&self) -> bool
pub const fn forward_down(&self) -> bool
Whether the thumb “forward” button is held.
pub const fn matches(&self, context: &ContextMenuMouseButton) -> bool
Source§impl MouseState
impl MouseState
Sourcepub const fn mouse_down(&self) -> bool
pub const fn mouse_down(&self) -> bool
Returns whether any mouse button (left, right or center) is currently held down
Snapshot the button-down flags as a MouseButtonState for drag tracking.
Trait Implementations§
Source§impl Clone for MouseState
impl Clone for MouseState
Source§fn clone(&self) -> MouseState
fn clone(&self) -> MouseState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more