[−][src]Struct sdl2::mouse::MouseState
Methods
impl MouseState
[src]
pub fn new(_e: &EventPump) -> MouseState
[src]
pub fn from_sdl_state(state: u32) -> MouseState
[src]
pub fn to_sdl_state(&self) -> u32
[src]
pub fn left(&self) -> bool
[src]
Returns true if the left mouse button is pressed.
Example
use sdl2::mouse::MouseButton; fn is_a_pressed(e: &sdl2::EventPump) -> bool { e.mouse_state().left() }
pub fn middle(&self) -> bool
[src]
Tests if the middle mouse button was pressed.
pub fn right(&self) -> bool
[src]
Tests if the right mouse button was pressed.
pub fn x1(&self) -> bool
[src]
Tests if the X1 mouse button was pressed.
pub fn x2(&self) -> bool
[src]
Tests if the X2 mouse button was pressed.
pub fn x(&self) -> i32
[src]
Returns the x coordinate of the state
pub fn y(&self) -> i32
[src]
Returns the y coordinate of the state
pub fn is_mouse_button_pressed(&self, mouse_button: MouseButton) -> bool
[src]
Returns true if the mouse button is pressed.
Example
use sdl2::mouse::MouseButton; fn is_left_pressed(e: &sdl2::EventPump) -> bool { e.mouse_state().is_mouse_button_pressed(MouseButton::Left) }
pub fn mouse_buttons(&self) -> MouseButtonIterator
[src]
Returns an iterator all mouse buttons with a boolean indicating if the scancode is pressed.
Example
use sdl2::mouse::MouseButton; use std::collections::HashMap; fn mouse_button_set(e: &sdl2::EventPump) -> HashMap<MouseButton, bool> { e.mouse_state().mouse_buttons().collect() } fn find_first_pressed(e: &sdl2::EventPump) -> bool { for (key,value) in mouse_button_set(e) { return value != false } false }
pub fn pressed_mouse_buttons(&self) -> PressedMouseButtonIterator
[src]
Returns an iterator of pressed mouse buttons.
Example
use sdl2::mouse::MouseButton; use std::collections::HashSet; fn pressed_mouse_button_set(e: &sdl2::EventPump) -> HashSet<MouseButton> { e.mouse_state().pressed_mouse_buttons().collect() } fn newly_pressed(old: &HashSet<MouseButton>, new: &HashSet<MouseButton>) -> HashSet<MouseButton> { new - old // sugar for: new.difference(old).collect() }
Trait Implementations
impl Clone for MouseState
[src]
fn clone(&self) -> MouseState
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for MouseState
[src]
impl Debug for MouseState
[src]
impl Eq for MouseState
[src]
impl Hash for MouseState
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<MouseState> for MouseState
[src]
fn eq(&self, other: &MouseState) -> bool
[src]
fn ne(&self, other: &MouseState) -> bool
[src]
impl StructuralEq for MouseState
[src]
impl StructuralPartialEq for MouseState
[src]
Auto Trait Implementations
impl RefUnwindSafe for MouseState
impl Send for MouseState
impl Sync for MouseState
impl Unpin for MouseState
impl UnwindSafe for MouseState
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,