#[repr(C)]pub struct MouseState {
pub mouse_cursor_type: OptionMouseCursorType,
pub cursor_position: CursorPosition,
pub is_cursor_locked: bool,
pub left_down: bool,
pub right_down: bool,
pub middle_down: bool,
pub scroll_x: OptionF32,
pub scroll_y: OptionF32,
}Expand description
Mouse position, cursor type, user scroll input, etc.
Fields§
§mouse_cursor_type: OptionMouseCursorTypeCurrent mouse cursor type, set to None if the cursor is hidden. (READWRITE)
cursor_position: CursorPositionWhere is the mouse cursor currently? Set to None if the window is not focused.
(READWRITE)
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)
scroll_x: OptionF32Scroll amount in pixels in the horizontal direction. Gets reset to 0 after every frame (READONLY)
scroll_y: OptionF32Scroll amount in pixels in the vertical direction. Gets reset to 0 after every frame (READONLY)
Implementations§
Source§impl MouseState
impl MouseState
pub fn matches(&self, context: &ContextMenuMouseButton) -> bool
Source§impl MouseState
impl MouseState
Sourcepub fn mouse_down(&self) -> bool
pub fn mouse_down(&self) -> bool
Returns whether any mouse button (left, right or center) is currently held down
pub fn get_scroll_x(&self) -> f32
pub fn get_scroll_y(&self) -> f32
pub fn get_scroll(&self) -> (f32, f32)
pub fn get_scroll_amount(&self) -> Option<(f32, f32)>
Sourcepub fn reset_scroll_to_zero(&mut self)
pub fn reset_scroll_to_zero(&mut self)
Function reset the scroll_x and scroll_y to None to clear the scroll amount
Trait Implementations§
Source§impl Clone for MouseState
impl Clone for MouseState
Source§fn clone(&self) -> MouseState
fn clone(&self) -> MouseState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MouseState
impl Debug for MouseState
Source§impl Default for MouseState
impl Default for MouseState
Source§impl PartialEq for MouseState
impl PartialEq for MouseState
Source§impl PartialOrd for MouseState
impl PartialOrd for MouseState
impl Copy for MouseState
impl StructuralPartialEq for MouseState
Auto Trait Implementations§
impl Freeze for MouseState
impl RefUnwindSafe for MouseState
impl Send for MouseState
impl Sync for MouseState
impl Unpin for MouseState
impl UnwindSafe for MouseState
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more