Skip to main content

UiEvent

Enum UiEvent 

Source
#[non_exhaustive]
pub enum UiEvent { Resize(u32, u32), CloseRequested, KeyPress(String), Mouse { x: f32, y: f32, }, MouseDown { button: MouseButton, x: f32, y: f32, modifiers: Modifiers, }, MouseUp { button: MouseButton, x: f32, y: f32, modifiers: Modifiers, }, MouseMove { x: f32, y: f32, }, Wheel(ScrollDelta), KeyDown { key: Key, modifiers: Modifiers, repeat: bool, }, KeyUp { key: Key, modifiers: Modifiers, }, ImePreedit { text: String, cursor: Option<(usize, usize)>, }, ImeCommit(String), }
Expand description

Events that the UI backend can emit.

This enum is #[non_exhaustive] — match arms must include a catch-all (_ => {}) to remain forward-compatible as new variants are added.

When deserialising with serde (feature = "serde"), unknown variants will produce a serde error. This is intentional: the API contract only promises forward-compatibility at the Rust source level via the #[non_exhaustive] catch-all; JSON consumers must handle new variants themselves.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Resize(u32, u32)

The window was resized to the given pixel dimensions.

§

CloseRequested

The user requested the window to close.

§

KeyPress(String)

A keyboard key was pressed (key name / character string).

§

Mouse

Mouse cursor position.

Fields

§x: f32

Horizontal position in logical pixels.

§y: f32

Vertical position in logical pixels.

§

MouseDown

A mouse button was pressed at the given position.

Fields

§button: MouseButton

Which button was pressed.

§x: f32

Horizontal position in logical pixels.

§y: f32

Vertical position in logical pixels.

§modifiers: Modifiers

Modifier keys held at the time of the press.

§

MouseUp

A mouse button was released at the given position.

Fields

§button: MouseButton

Which button was released.

§x: f32

Horizontal position in logical pixels.

§y: f32

Vertical position in logical pixels.

§modifiers: Modifiers

Modifier keys held at the time of the release.

§

MouseMove

The mouse moved to a new position (no button-state change implied).

Fields

§x: f32

Horizontal position in logical pixels.

§y: f32

Vertical position in logical pixels.

§

Wheel(ScrollDelta)

A scroll-wheel / trackpad scroll occurred.

§

KeyDown

A key was pressed (or auto-repeated).

Fields

§key: Key

The logical key.

§modifiers: Modifiers

Modifier keys held.

§repeat: bool

Whether this is an auto-repeat (key held down).

§

KeyUp

A key was released.

Fields

§key: Key

The logical key.

§modifiers: Modifiers

Modifier keys held.

§

ImePreedit

IME preedit — composition in progress.

text is the current composition string. cursor is the byte-offset range (start, end) within text that should be highlighted as the cursor/selection; None means no explicit cursor hint.

Note: on the egui forwarding path the cursor range is not forwarded (egui 0.34’s ImeEvent::Preedit only accepts a String).

Fields

§text: String

Composition string being entered.

§cursor: Option<(usize, usize)>

Optional byte-range cursor hint within text.

§

ImeCommit(String)

IME commit — final committed text after composition ends.

Callers should insert text into the active text-input field.

Trait Implementations§

Source§

impl Clone for UiEvent

Source§

fn clone(&self) -> UiEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for UiEvent

Source§

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

Formats the value using the given formatter. Read more

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§

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
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,

Source§

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>,

Source§

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>,

Source§

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.