Event

Enum Event 

Source
pub enum Event {
Show 27 variants MouseMove { position: Point, }, MouseDown { position: Point, button: MouseButton, }, MouseUp { position: Point, button: MouseButton, }, Scroll { delta_x: f32, delta_y: f32, }, KeyDown { key: Key, }, KeyUp { key: Key, }, TextInput { text: String, }, FocusIn, FocusOut, MouseEnter, MouseLeave, Resize { width: f32, height: f32, }, TouchStart { id: TouchId, position: Point, pressure: f32, }, TouchMove { id: TouchId, position: Point, pressure: f32, }, TouchEnd { id: TouchId, position: Point, }, TouchCancel { id: TouchId, }, PointerDown { pointer_id: PointerId, pointer_type: PointerType, position: Point, pressure: f32, is_primary: bool, button: Option<MouseButton>, }, PointerMove { pointer_id: PointerId, pointer_type: PointerType, position: Point, pressure: f32, is_primary: bool, }, PointerUp { pointer_id: PointerId, pointer_type: PointerType, position: Point, is_primary: bool, button: Option<MouseButton>, }, PointerCancel { pointer_id: PointerId, }, PointerEnter { pointer_id: PointerId, pointer_type: PointerType, }, PointerLeave { pointer_id: PointerId, pointer_type: PointerType, }, GesturePinch { scale: f32, center: Point, state: GestureState, }, GestureRotate { angle: f32, center: Point, state: GestureState, }, GesturePan { delta: Point, velocity: Point, state: GestureState, }, GestureLongPress { position: Point, }, GestureTap { position: Point, count: u8, },
}
Expand description

Input event types.

Variants§

§

MouseMove

Mouse moved to position

Fields

§position: Point

New position

§

MouseDown

Mouse button pressed

Fields

§position: Point

Position of click

§button: MouseButton

Button pressed

§

MouseUp

Mouse button released

Fields

§position: Point

Position of release

§button: MouseButton

Button released

§

Scroll

Mouse wheel scrolled

Fields

§delta_x: f32

Horizontal scroll delta

§delta_y: f32

Vertical scroll delta

§

KeyDown

Key pressed

Fields

§key: Key

Key pressed

§

KeyUp

Key released

Fields

§key: Key

Key released

§

TextInput

Text input received

Fields

§text: String

Input text

§

FocusIn

Widget gained focus

§

FocusOut

Widget lost focus

§

MouseEnter

Mouse entered widget bounds

§

MouseLeave

Mouse left widget bounds

§

Resize

Window resized

Fields

§width: f32

New width

§height: f32

New height

§

TouchStart

Touch started

Fields

§id: TouchId

Touch identifier

§position: Point

Touch position

§pressure: f32

Touch pressure (0.0 to 1.0)

§

TouchMove

Touch moved

Fields

§id: TouchId

Touch identifier

§position: Point

New position

§pressure: f32

Touch pressure

§

TouchEnd

Touch ended

Fields

§id: TouchId

Touch identifier

§position: Point

Final position

§

TouchCancel

Touch cancelled (e.g., palm rejection)

Fields

§id: TouchId

Touch identifier

§

PointerDown

Pointer down

Fields

§pointer_id: PointerId

Pointer ID

§pointer_type: PointerType

Pointer type

§position: Point

Position

§pressure: f32

Pressure

§is_primary: bool

Is primary pointer

§button: Option<MouseButton>

Button (for mouse pointers)

§

PointerMove

Pointer moved

Fields

§pointer_id: PointerId

Pointer ID

§pointer_type: PointerType

Pointer type

§position: Point

Position

§pressure: f32

Pressure

§is_primary: bool

Is primary pointer

§

PointerUp

Pointer up

Fields

§pointer_id: PointerId

Pointer ID

§pointer_type: PointerType

Pointer type

§position: Point

Position

§is_primary: bool

Is primary pointer

§button: Option<MouseButton>

Button (for mouse pointers)

§

PointerCancel

Pointer cancelled

Fields

§pointer_id: PointerId

Pointer ID

§

PointerEnter

Pointer entered element

Fields

§pointer_id: PointerId

Pointer ID

§pointer_type: PointerType

Pointer type

§

PointerLeave

Pointer left element

Fields

§pointer_id: PointerId

Pointer ID

§pointer_type: PointerType

Pointer type

§

GesturePinch

Pinch gesture

Fields

§scale: f32

Scale factor

§center: Point

Center point

§state: GestureState

Gesture state

§

GestureRotate

Rotate gesture

Fields

§angle: f32

Rotation angle in radians

§center: Point

Center point

§state: GestureState

Gesture state

§

GesturePan

Pan/drag gesture

Fields

§delta: Point

Translation delta

§velocity: Point

Velocity

§state: GestureState

Gesture state

§

GestureLongPress

Long press gesture

Fields

§position: Point

Position

§

GestureTap

Tap gesture

Fields

§position: Point

Position

§count: u8

Number of taps (1 = single, 2 = double)

Implementations§

Source§

impl Event

Source

pub const fn is_mouse(&self) -> bool

Check if this is a mouse event.

Source

pub const fn is_keyboard(&self) -> bool

Check if this is a keyboard event.

Source

pub const fn is_focus(&self) -> bool

Check if this is a focus event.

Source

pub const fn is_touch(&self) -> bool

Check if this is a touch event.

Source

pub const fn is_pointer(&self) -> bool

Check if this is a pointer event.

Source

pub const fn is_gesture(&self) -> bool

Check if this is a gesture event.

Source

pub const fn position(&self) -> Option<Point>

Get the position if this is a positional event.

Source

pub const fn touch_id(&self) -> Option<TouchId>

Get the touch ID if this is a touch event.

Source

pub const fn pointer_id(&self) -> Option<PointerId>

Get the pointer ID if this is a pointer event.

Source

pub const fn pointer_type(&self) -> Option<PointerType>

Get the pointer type if this is a pointer event.

Source

pub const fn pressure(&self) -> Option<f32>

Get pressure if available (0.0 to 1.0).

Source

pub const fn gesture_state(&self) -> Option<GestureState>

Get gesture state if this is a gesture event.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0§

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<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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§

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 Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,