Struct ggez::event::MouseState [−][src]
pub struct MouseState { /* fields omitted */ }
Methods
impl MouseState
[src]
impl MouseState
pub fn new(_e: &EventPump) -> MouseState
[src]
pub fn new(_e: &EventPump) -> MouseState
pub fn from_sdl_state(state: u32) -> MouseState
[src]
pub fn from_sdl_state(state: u32) -> MouseState
pub fn to_sdl_state(&self) -> u32
[src]
pub fn to_sdl_state(&self) -> u32
pub fn left(&self) -> bool
[src]
pub fn left(&self) -> bool
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]
pub fn middle(&self) -> bool
Tests if the middle mouse button was pressed.
pub fn right(&self) -> bool
[src]
pub fn right(&self) -> bool
Tests if the right mouse button was pressed.
pub fn x1(&self) -> bool
[src]
pub fn x1(&self) -> bool
Tests if the X1 mouse button was pressed.
pub fn x2(&self) -> bool
[src]
pub fn x2(&self) -> bool
Tests if the X2 mouse button was pressed.
pub fn x(&self) -> i32
[src]
pub fn x(&self) -> i32
Returns the x coordinate of the state
pub fn y(&self) -> i32
[src]
pub fn y(&self) -> i32
Returns the y coordinate of the state
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) }
ⓘImportant traits for MouseButtonIterator<'a>
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 }
ⓘImportant traits for PressedMouseButtonIterator<'a>
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 Hash for MouseState
[src]
impl Hash for MouseState
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Clone for MouseState
[src]
impl Clone for MouseState
fn clone(&self) -> MouseState
[src]
fn clone(&self) -> MouseState
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for MouseState
[src]
impl Copy for MouseState
impl Eq for MouseState
[src]
impl Eq for MouseState
impl PartialEq<MouseState> for MouseState
[src]
impl PartialEq<MouseState> for MouseState
fn eq(&self, other: &MouseState) -> bool
[src]
fn eq(&self, other: &MouseState) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &MouseState) -> bool
[src]
fn ne(&self, other: &MouseState) -> bool
This method tests for !=
.
Auto Trait Implementations
impl Send for MouseState
impl Send for MouseState
impl Sync for MouseState
impl Sync for MouseState