pub enum Event {
KeyDown(Key),
KeyUp(Key),
MouseMove {
x: i32,
y: i32,
},
MouseButton {
x: i32,
y: i32,
button: MouseButton,
pressed: bool,
},
Scroll {
delta: i32,
},
Close,
Resize {
width: u32,
height: u32,
},
}Expand description
A GUI input event.
Variants§
KeyDown(Key)
A key was pressed.
KeyUp(Key)
A key was released.
MouseMove
The pointer moved to (x, y) in window-content coordinates.
MouseButton
A mouse button was pressed or released.
Scroll
The mouse wheel scrolled. delta is positive = up, negative = down.
Close
The window was asked to close (e.g., the user clicked ✕).
Resize
The window was resized.
Implementations§
Source§impl Event
impl Event
pub fn is_close(&self) -> bool
Sourcepub fn as_key_down(&self) -> Option<Key>
pub fn as_key_down(&self) -> Option<Key>
Returns the key if this is a KeyDown event.
Sourcepub fn as_mouse_btn(&self) -> Option<(i32, i32, MouseButton, bool)>
pub fn as_mouse_btn(&self) -> Option<(i32, i32, MouseButton, bool)>
Returns (x, y, button, pressed) if this is a MouseButton event.
Sourcepub fn as_mouse_move(&self) -> Option<(i32, i32)>
pub fn as_mouse_move(&self) -> Option<(i32, i32)>
Returns (x, y) if this is a MouseMove event.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
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
Mutably borrows from an owned value. Read more