Enum tetra::Event [−][src]
#[non_exhaustive] pub enum Event {}Show variants
Resized { width: i32, height: i32, }, Restored, Minimized, Maximized, FocusGained, FocusLost, KeyPressed { key: Key, }, KeyReleased { key: Key, }, MouseButtonPressed { button: MouseButton, }, MouseButtonReleased { button: MouseButton, }, MouseMoved { position: Vec2<f32>, delta: Vec2<f32>, }, MouseWheelMoved { amount: Vec2<i32>, }, GamepadAdded { id: usize, }, GamepadRemoved { id: usize, }, GamepadButtonPressed { id: usize, button: GamepadButton, }, GamepadButtonReleased { id: usize, button: GamepadButton, }, GamepadAxisMoved { id: usize, axis: GamepadAxis, position: f32, }, GamepadStickMoved { id: usize, stick: GamepadStick, position: Vec2<f32>, }, TextInput { text: String, }, FileDropped { path: PathBuf, },
Expand description
Events that can occur while the game is running.
State::event
will receive events as they occur.
Examples
The events
example demonstrates how to handle events.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Expand description
The game window was resized.
Show fields
Expand description
The game window was restored to normal size and position by the user, either by un-minimizing or un-maximizing.
Expand description
The game window was minimized by the user.
Expand description
The game window was maximized by the user.
Expand description
The game window was focused by the user.
Expand description
The game window was un-focused by the user.
Expand description
A key on the keyboard was pressed.
Show fields
Fields of KeyPressed
key: Key
Expand description
The key that was pressed.
Expand description
A key on the keyboard was released.
Show fields
Fields of KeyReleased
key: Key
Expand description
The key that was released.
Expand description
A button on the mouse was pressed.
Show fields
Fields of MouseButtonPressed
Expand description
The button that was pressed.
Expand description
A button on the mouse was released.
Show fields
Fields of MouseButtonReleased
Expand description
The button that was released.
Expand description
The mouse was moved.
Show fields
Fields of MouseMoved
position: Vec2<f32>
Expand description
The new position of the mouse, in window co-ordinates.
If relative mouse mode is enabled, this field is not guarenteed to update.
delta: Vec2<f32>
Expand description
The movement of the mouse, relative to the position
of the previous
MouseMoved
event.
Expand description
The mouse wheel was moved.
Show fields
Fields of MouseWheelMoved
amount: Vec2<i32>
Expand description
The amount that the wheel was moved.
Most ‘normal’ mice can only scroll vertically, but some devices can also scroll horizontally. Use the Y component of the returned vector if you don’t care about horizontal scroll.
Positive values correspond to scrolling up/right, negative values correspond to scrolling down/left.
Expand description
A gamepad was connected to the system.
Show fields
Fields of GamepadAdded
id: usize
Expand description
The ID that was assigned to the gamepad.
Expand description
A gamepad was removed from the system.
Show fields
Fields of GamepadRemoved
id: usize
Expand description
The ID of the gamepad that was removed.
Expand description
A button on a gamepad was pressed.
Show fields
Fields of GamepadButtonPressed
Expand description
A button on a gamepad was released.
Show fields
Fields of GamepadButtonReleased
Expand description
An axis on a gamepad was moved.
Show fields
Fields of GamepadAxisMoved
id: usize
Expand description
The ID of the gamepad.
axis: GamepadAxis
Expand description
The axis that was moved.
position: f32
Expand description
The new position of the axis.
Expand description
A control stick on a gamepad was moved.
Show fields
Fields of GamepadStickMoved
id: usize
Expand description
The ID of the gamepad.
stick: GamepadStick
Expand description
The stick that was moved.
position: Vec2<f32>
Expand description
The new position of the stick.
Expand description
The user typed some text.
Show fields
Fields of TextInput
text: String
Expand description
The text that was typed by the user.
Expand description
The user dropped a file into the window.
This event will be fired multiple times if the user dropped multiple files at the same time.
Note that on MacOS, you must edit your info.plist
file to set which document types
you want your application to support,
otherwise no FileDropped
events will be fired.
Show fields
Fields of FileDropped
path: PathBuf
Expand description
The path of the file that was dropped.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more