Enum sdl2::event::Event

source ·
pub enum Event {
Show 39 variants Quit { timestamp: u32, }, AppTerminating { timestamp: u32, }, AppLowMemory { timestamp: u32, }, AppWillEnterBackground { timestamp: u32, }, AppDidEnterBackground { timestamp: u32, }, AppWillEnterForeground { timestamp: u32, }, AppDidEnterForeground { timestamp: u32, }, Window { timestamp: u32, window_id: u32, win_event: WindowEvent, }, KeyDown { timestamp: u32, window_id: u32, keycode: Option<Keycode>, scancode: Option<Scancode>, keymod: Mod, repeat: bool, }, KeyUp { timestamp: u32, window_id: u32, keycode: Option<Keycode>, scancode: Option<Scancode>, keymod: Mod, repeat: bool, }, TextEditing { timestamp: u32, window_id: u32, text: String, start: i32, length: i32, }, TextInput { timestamp: u32, window_id: u32, text: String, }, MouseMotion { timestamp: u32, window_id: u32, which: u32, mousestate: MouseState, x: i32, y: i32, xrel: i32, yrel: i32, }, MouseButtonDown { timestamp: u32, window_id: u32, which: u32, mouse_btn: MouseButton, clicks: u8, x: i32, y: i32, }, MouseButtonUp { timestamp: u32, window_id: u32, which: u32, mouse_btn: MouseButton, clicks: u8, x: i32, y: i32, }, MouseWheel { timestamp: u32, window_id: u32, which: u32, x: i32, y: i32, direction: MouseWheelDirection, }, JoyAxisMotion { timestamp: u32, which: i32, axis_idx: u8, value: i16, }, JoyBallMotion { timestamp: u32, which: i32, ball_idx: u8, xrel: i16, yrel: i16, }, JoyHatMotion { timestamp: u32, which: i32, hat_idx: u8, state: HatState, }, JoyButtonDown { timestamp: u32, which: i32, button_idx: u8, }, JoyButtonUp { timestamp: u32, which: i32, button_idx: u8, }, JoyDeviceAdded { timestamp: u32, which: u32, }, JoyDeviceRemoved { timestamp: u32, which: i32, }, ControllerAxisMotion { timestamp: u32, which: i32, axis: Axis, value: i16, }, ControllerButtonDown { timestamp: u32, which: i32, button: Button, }, ControllerButtonUp { timestamp: u32, which: i32, button: Button, }, ControllerDeviceAdded { timestamp: u32, which: u32, }, ControllerDeviceRemoved { timestamp: u32, which: i32, }, ControllerDeviceRemapped { timestamp: u32, which: i32, }, FingerDown { timestamp: u32, touch_id: i64, finger_id: i64, x: f32, y: f32, dx: f32, dy: f32, pressure: f32, }, FingerUp { timestamp: u32, touch_id: i64, finger_id: i64, x: f32, y: f32, dx: f32, dy: f32, pressure: f32, }, FingerMotion { timestamp: u32, touch_id: i64, finger_id: i64, x: f32, y: f32, dx: f32, dy: f32, pressure: f32, }, DollarGesture { timestamp: u32, touch_id: i64, gesture_id: i64, num_fingers: u32, error: f32, x: f32, y: f32, }, DollarRecord { timestamp: u32, touch_id: i64, gesture_id: i64, num_fingers: u32, error: f32, x: f32, y: f32, }, MultiGesture { timestamp: u32, touch_id: i64, d_theta: f32, d_dist: f32, x: f32, y: f32, num_fingers: u16, }, ClipboardUpdate { timestamp: u32, }, DropFile { timestamp: u32, window_id: u32, filename: String, }, User { timestamp: u32, window_id: u32, type_: u32, code: i32, data1: *mut c_void, data2: *mut c_void, }, Unknown { timestamp: u32, type_: u32, },
}
Expand description

Different event types.

Variants§

§

Quit

Fields

§timestamp: u32
§

AppTerminating

Fields

§timestamp: u32
§

AppLowMemory

Fields

§timestamp: u32
§

AppWillEnterBackground

Fields

§timestamp: u32
§

AppDidEnterBackground

Fields

§timestamp: u32
§

AppWillEnterForeground

Fields

§timestamp: u32
§

AppDidEnterForeground

Fields

§timestamp: u32
§

Window

Fields

§timestamp: u32
§window_id: u32
§win_event: WindowEvent
§

KeyDown

Fields

§timestamp: u32
§window_id: u32
§keycode: Option<Keycode>
§scancode: Option<Scancode>
§keymod: Mod
§repeat: bool
§

KeyUp

Fields

§timestamp: u32
§window_id: u32
§keycode: Option<Keycode>
§scancode: Option<Scancode>
§keymod: Mod
§repeat: bool
§

TextEditing

Fields

§timestamp: u32
§window_id: u32
§text: String
§start: i32
§length: i32
§

TextInput

Fields

§timestamp: u32
§window_id: u32
§text: String
§

MouseMotion

Fields

§timestamp: u32
§window_id: u32
§which: u32
§mousestate: MouseState
§xrel: i32
§yrel: i32
§

MouseButtonDown

Fields

§timestamp: u32
§window_id: u32
§which: u32
§mouse_btn: MouseButton
§clicks: u8
§

MouseButtonUp

Fields

§timestamp: u32
§window_id: u32
§which: u32
§mouse_btn: MouseButton
§clicks: u8
§

MouseWheel

Fields

§timestamp: u32
§window_id: u32
§which: u32
§

JoyAxisMotion

Fields

§timestamp: u32
§which: i32

The joystick’s id

§axis_idx: u8
§value: i16
§

JoyBallMotion

Fields

§timestamp: u32
§which: i32

The joystick’s id

§ball_idx: u8
§xrel: i16
§yrel: i16
§

JoyHatMotion

Fields

§timestamp: u32
§which: i32

The joystick’s id

§hat_idx: u8
§state: HatState
§

JoyButtonDown

Fields

§timestamp: u32
§which: i32

The joystick’s id

§button_idx: u8
§

JoyButtonUp

Fields

§timestamp: u32
§which: i32

The joystick’s id

§button_idx: u8
§

JoyDeviceAdded

Fields

§timestamp: u32
§which: u32

The newly added joystick’s joystick_index

§

JoyDeviceRemoved

Fields

§timestamp: u32
§which: i32

The joystick’s id

§

ControllerAxisMotion

Fields

§timestamp: u32
§which: i32

The controller’s joystick id

§axis: Axis
§value: i16
§

ControllerButtonDown

Fields

§timestamp: u32
§which: i32

The controller’s joystick id

§button: Button
§

ControllerButtonUp

Fields

§timestamp: u32
§which: i32

The controller’s joystick id

§button: Button
§

ControllerDeviceAdded

Fields

§timestamp: u32
§which: u32

The newly added controller’s joystick_index

§

ControllerDeviceRemoved

Fields

§timestamp: u32
§which: i32

The controller’s joystick id

§

ControllerDeviceRemapped

Fields

§timestamp: u32
§which: i32

The controller’s joystick id

§

FingerDown

Fields

§timestamp: u32
§touch_id: i64
§finger_id: i64
§dx: f32
§dy: f32
§pressure: f32
§

FingerUp

Fields

§timestamp: u32
§touch_id: i64
§finger_id: i64
§dx: f32
§dy: f32
§pressure: f32
§

FingerMotion

Fields

§timestamp: u32
§touch_id: i64
§finger_id: i64
§dx: f32
§dy: f32
§pressure: f32
§

DollarGesture

Fields

§timestamp: u32
§touch_id: i64
§gesture_id: i64
§num_fingers: u32
§error: f32
§

DollarRecord

Fields

§timestamp: u32
§touch_id: i64
§gesture_id: i64
§num_fingers: u32
§error: f32
§

MultiGesture

Fields

§timestamp: u32
§touch_id: i64
§d_theta: f32
§d_dist: f32
§num_fingers: u16
§

ClipboardUpdate

Fields

§timestamp: u32
§

DropFile

Fields

§timestamp: u32
§window_id: u32
§filename: String
§

User

Fields

§timestamp: u32
§window_id: u32
§type_: u32
§code: i32
§

Unknown

Fields

§timestamp: u32
§type_: u32

Implementations§

source§

impl Event

source

pub fn unwrap_keymod(keymod_option: Option<Mod>) -> Mod

source

pub fn is_user_event(&self) -> bool

source

pub fn as_user_event_type<T: Any>(&self) -> Option<T>

Trait Implementations§

source§

impl Clone for Event

source§

fn clone(&self) -> Event

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Event

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Event

source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Send for Event

This does not auto-derive because User’s data fields can be used to store pointers to types that are !Send. Dereferencing these as pointers requires using unsafe and ensuring your own safety guarantees.

source§

impl StructuralPartialEq for Event

source§

impl Sync for Event

This does not auto-derive because User’s data fields can be used to store pointers to types that are !Sync. Dereferencing these as pointers requires using unsafe and ensuring your own safety guarantees.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.