#[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
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.
MouseDown
A mouse button was pressed at the given position.
Fields
Which button was pressed.
MouseUp
A mouse button was released at the given position.
Fields
Which button was released.
MouseMove
The mouse moved to a new position (no button-state change implied).
Wheel(ScrollDelta)
A scroll-wheel / trackpad scroll occurred.
KeyDown
A key was pressed (or auto-repeated).
Fields
KeyUp
A key was released.
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
ImeCommit(String)
IME commit — final committed text after composition ends.
Callers should insert text into the active text-input field.