Struct ggez::input::mouse::MouseContext
source · pub struct MouseContext { /* private fields */ }
Expand description
Stores state information for the mouse input.
Implementations§
source§impl MouseContext
impl MouseContext
sourcepub fn cursor_type(&self) -> CursorIcon
pub fn cursor_type(&self) -> CursorIcon
Returns the current mouse cursor type of the window.
Set whether or not the mouse is hidden (invisible)
sourcepub fn position(&self) -> Point2<f32>
pub fn position(&self) -> Point2<f32>
Get the current position of the mouse cursor, in pixels.
Complement to set_position()
.
Uses strictly window-only coordinates.
sourcepub fn delta(&self) -> Point2<f32>
pub fn delta(&self) -> Point2<f32>
Get the distance the cursor was moved during the current frame, in pixels.
Returns whether or not the given mouse button is pressed.
Returns whether or not the given mouse button has been pressed this frame.
Returns whether or not the given mouse button has been released this frame.
sourcepub fn handle_move(&mut self, new_x: f32, new_y: f32)
pub fn handle_move(&mut self, new_x: f32, new_y: f32)
Updates delta and position values. The inputs are interpreted as pixel coordinates inside the window.
This function is called internally whenever the mouse moves to a new location.
It can also be used to simulate mouse input.
(It gets called inside the default implementation of the
touch_event
, for example.)
Calling this function alone won’t trigger a
mouse_motion_event
though.
(Note that the default implementation of
touch_event
DOES trigger one, but
it does so by invoking it on the EventHandler
manually.)
sourcepub fn reset_delta(&mut self)
pub fn reset_delta(&mut self)
Resets the value returned by mouse::delta
to zero.
You shouldn’t need to call this, except when you’re running your own event loop.
In this case call it right at the end, after draw
and update
have finished.
sourcepub fn save_mouse_state(&mut self)
pub fn save_mouse_state(&mut self)
Copies the current state of the mouse buttons into the context. If you are writing your own event loop
you need to call this at the end of every update in order to use the functions is_button_just_pressed
and is_button_just_released
. Otherwise this is handled for you.
sourcepub fn last_delta(&self) -> Point2<f32>
pub fn last_delta(&self) -> Point2<f32>
Get the distance the cursor was moved between the latest two mouse_motion_events
.
Really useful only if you are writing your own event loop
Trait Implementations§
source§impl Clone for MouseContext
impl Clone for MouseContext
source§fn clone(&self) -> MouseContext
fn clone(&self) -> MouseContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more