Skip to main content

UiEvent

Enum UiEvent 

Source
#[non_exhaustive]
pub enum UiEvent {
Show 63 variants Clicked { widget_id: WidgetId, }, Toggled { widget_id: WidgetId, checked: bool, }, TextChanged { widget_id: WidgetId, text: String, }, SelectionChanged { widget_id: WidgetId, selected: Option<String>, index: Option<usize>, }, MultiSelectionChanged { widget_id: WidgetId, indices: Vec<usize>, }, GridCellClicked { widget_id: WidgetId, row: usize, col: usize, }, GridSelectionChanged { widget_id: WidgetId, selected_ranges: Vec<(usize, usize)>, }, GridCellEditingStarted { widget_id: WidgetId, row: usize, col: usize, }, GridCellEditingFinished { widget_id: WidgetId, row: usize, col: usize, new_value: String, }, Activated { widget_id: WidgetId, index: Option<usize>, }, TextSubmitted { widget_id: WidgetId, text: String, }, SuggestionSelected { widget_id: WidgetId, text: String, }, SuggestionDismissed { widget_id: WidgetId, }, ValueChanged { widget_id: WidgetId, value: i32, }, DateChanged { widget_id: WidgetId, iso_date: String, }, LinkActivated { widget_id: WidgetId, url: String, }, ProgressChanged { widget_id: WidgetId, value: f64, }, MenuItemSelected { menu_id: MenuId, item_id: MenuItemId, }, DialogResponse { token: u64, confirmed: bool, }, FileDialogResponse { token: u64, paths: Vec<PathBuf>, }, ColorChanged { widget_id: WidgetId, color: Rgba, }, ColorSelected { widget_id: WidgetId, color: Option<Rgba>, }, FontChanged { widget_id: WidgetId, descriptor: FontDescriptor, }, FontSelected { widget_id: WidgetId, selection: Option<(FontDescriptor, FontEffects)>, }, HelpRequested { widget_id: WidgetId, }, ToolActivated { widget_id: WidgetId, tool_id: ToolId, }, ToolToggled { widget_id: WidgetId, tool_id: ToolId, checked: bool, }, ToolDropdown { widget_id: WidgetId, tool_id: ToolId, }, ToolHovered { widget_id: WidgetId, tool_id: Option<ToolId>, }, ToolContext { widget_id: WidgetId, tool_id: ToolId, }, DragStarted { widget_id: WidgetId, indices: Vec<usize>, }, Dropped { widget_id: WidgetId, target_index: usize, source_indices: Vec<usize>, }, FilesDropped { widget_id: WidgetId, paths: Vec<String>, }, UrlsDropped { widget_id: WidgetId, urls: Vec<String>, offset: Option<usize>, }, TextDropped { widget_id: WidgetId, text: String, offset: Option<usize>, }, DragSessionStarted { widget_id: WidgetId, session: DragSessionId, kinds: Vec<DragPayloadKind>, }, DragEntered { target: WidgetId, session: DragSessionId, position: (i32, i32), offered: Vec<String>, }, DragMoved { target: WidgetId, session: DragSessionId, position: (i32, i32), }, DragExited { target: WidgetId, session: DragSessionId, }, DragDropped { target: WidgetId, session: DragSessionId, position: (i32, i32), payload: DragPayload, effect: DropEffect, }, DragCancelled { session: DragSessionId, reason: DropCancelReason, }, WindowResized { widget_id: WidgetId, width: i32, height: i32, }, SplitPaneMoved { widget_id: WidgetId, position: i32, extent: i32, }, CloseRequested { widget_id: WidgetId, }, WindowClosed { widget_id: WidgetId, }, PopupDismissed { widget_id: WidgetId, reason: PopupDismissReason, }, TimerFired { timer: TimerId, elapsed: Duration, missed: u32, }, MotionTicked { motion: MotionId, widget_id: WidgetId, progress: f32, }, MotionFinished { motion: MotionId, widget_id: WidgetId, }, PointerDown { widget_id: WidgetId, x: f32, y: f32, button: u8, }, PointerMove { widget_id: WidgetId, x: f32, y: f32, }, PointerUp { widget_id: WidgetId, x: f32, y: f32, button: u8, }, KeyDown { widget_id: WidgetId, key: String, ctrl: bool, shift: bool, alt: bool, }, KeyUp { widget_id: WidgetId, key: String, ctrl: bool, shift: bool, alt: bool, }, Char { widget_id: WidgetId, text: String, }, CompositionChanged { widget_id: WidgetId, text: Option<String>, }, FocusChanged { widget_id: WidgetId, focused: bool, }, ThemeChanged { mode: ThemeMode, high_contrast: bool, }, DisplayChanged { display: DisplayInfo, }, TasksPending, Task(TaskEvent), CalendarDateSelected { widget_id: WidgetId, date: CalendarDate, selected_dates: Vec<CalendarDate>, }, CalendarMonthChanged { widget_id: WidgetId, year: i32, month: u32, },
}

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

Clicked

Fields

§widget_id: WidgetId
§

Toggled

Fields

§widget_id: WidgetId
§checked: bool
§

TextChanged

Fields

§widget_id: WidgetId
§text: String
§

SelectionChanged

Fields

§widget_id: WidgetId
§selected: Option<String>
§index: Option<usize>

Position of the selection within the widget (list/combo/tab), when the backend can report it. Prefer this over matching by selected text, which is not unique.

§

MultiSelectionChanged

Multi-select list/tree widgets report their selection set by row index.

Fields

§widget_id: WidgetId
§indices: Vec<usize>
§

GridCellClicked

A grid cell was clicked (DataGrid).

Fields

§widget_id: WidgetId
§row: usize
§col: usize
§

GridSelectionChanged

A range of cells was selected (DataGrid).

Fields

§widget_id: WidgetId
§selected_ranges: Vec<(usize, usize)>

List of (row, col) tuples representing selected cells

§

GridCellEditingStarted

In-place editing started on a cell.

Fields

§widget_id: WidgetId
§row: usize
§col: usize
§

GridCellEditingFinished

In-place editing finished on a cell.

Fields

§widget_id: WidgetId
§row: usize
§col: usize
§new_value: String
§

Activated

A row (list/tree widgets) or line (DataGrid) was activated via double-click; index is the row/line position when the backend can report it.

Fields

§widget_id: WidgetId
§index: Option<usize>
§

TextSubmitted

Fields

§widget_id: WidgetId
§text: String
§

SuggestionSelected

The user accepted a TextInput completion suggestion.

Emitted at most once per popup session, when the user commits a suggestion with Enter or a click. The application applies text through crate::Ui::set_text and moves focus as it sees fit; a popup closed without acceptance reports UiEvent::SuggestionDismissed instead.

Fields

§widget_id: WidgetId
§text: String
§

SuggestionDismissed

The completion popup closed without acceptance: Escape, blur, or a click elsewhere. Never follows a SuggestionSelected for the same popup session.

Fields

§widget_id: WidgetId
§

ValueChanged

Fields

§widget_id: WidgetId
§value: i32
§

DateChanged

Fields

§widget_id: WidgetId
§iso_date: String
§

LinkActivated

Fields

§widget_id: WidgetId
§

ProgressChanged

Fields

§widget_id: WidgetId
§value: f64
§

MenuItemSelected

Fields

§menu_id: MenuId
§item_id: MenuItemId
§

DialogResponse

A programmatic confirm dialog (Ui::show_confirm_dialog) was answered; token matches the value returned when the dialog was shown and confirmed is the Yes/No outcome.

Fields

§token: u64
§confirmed: bool
§

FileDialogResponse

A function-style file dialog (Ui::show_file_dialog) was answered; token matches the value returned when it was shown. paths holds the chosen file(s) or folder, and is empty when the user cancelled.

Fields

§token: u64
§paths: Vec<PathBuf>
§

ColorChanged

Live colour preview from an open ColorDialog.

Capability-gated: lanes advertise whether the native chooser emits previews, and a lane without one never sends this event. Receiving it means the user is hovering a candidate colour — the dialog is still open, so applications that render the candidate must restore their previous state when the final UiEvent::ColorSelected is a cancel.

Fields

§widget_id: WidgetId
§color: Rgba
§

ColorSelected

Final answer from a ColorDialog: the accepted colour, or None when the user cancelled.

Exactly one of these is delivered per activation, and an accept also refreshes the widget’s color_dialog_data.initial so reopening starts where the user finished.

Fields

§widget_id: WidgetId
§color: Option<Rgba>
§

FontChanged

Live font preview from an open FontDialog.

Capability-gated like UiEvent::ColorChanged: it arrives while the dialog is open, so applications that render the candidate must restore their previous state when the final selection is a cancel. The size is already clamped to the dialog’s configured range.

Fields

§widget_id: WidgetId
§descriptor: FontDescriptor
§

FontSelected

Final answer from a FontDialog: the accepted descriptor and effects, or None when the user cancelled.

Exactly one of these is delivered per activation. An accept refreshes the widget’s font_dialog_data (initial descriptor and effects) so reopening starts where the user finished, with the shared size clamp applied to the stored value.

Fields

§widget_id: WidgetId
§

HelpRequested

The user asked for help from a picker dialog whose lane offers a help affordance (capability font_dialog_help).

Fields

§widget_id: WidgetId
§

ToolActivated

A toolbar tool was activated by the user.

A checkable tool reports UiEvent::ToolToggled instead, a dropdown tool reports UiEvent::ToolDropdown, and a disabled or hidden tool reports nothing — so a click produces exactly one of the three.

Fields

§widget_id: WidgetId
§tool_id: ToolId
§

ToolToggled

A user toggled a checkable toolbar tool; checked is the new state.

One event is delivered per changed tool: checking a radio member unchecks the previous member, which arrives as its own event in toolbar order. Programmatic crate::Ui::set_tool_state never emits these — it returns the changed tools to the caller instead.

Fields

§widget_id: WidgetId
§tool_id: ToolId
§checked: bool
§

ToolDropdown

The user asked a dropdown tool to open its menu.

The application composes the menu with the existing menu API after receiving this event; the shared model never builds popup content.

Fields

§widget_id: WidgetId
§tool_id: ToolId
§

ToolHovered

The pointer entered (Some) or left (None) a toolbar tool (capability-gated: lanes that cannot report hot-item changes never send it).

Fields

§widget_id: WidgetId
§tool_id: Option<ToolId>
§

ToolContext

A toolbar tool was right-clicked, asking for a context menu.

Fields

§widget_id: WidgetId
§tool_id: ToolId
§

DragStarted

A row drag began on a drag-enabled widget carrying the dragged row indices (usually the current selection).

Fields

§widget_id: WidgetId
§indices: Vec<usize>
§

Dropped

Rows were dropped onto target_index of the receiving widget; the app performs the move through its core model and refreshes.

Fields

§widget_id: WidgetId
§target_index: usize
§source_indices: Vec<usize>
§

FilesDropped

External files were dropped onto a window or widget from the OS shell (e.g. Explorer, Finder, Nautilus).

Fields

§widget_id: WidgetId
§paths: Vec<String>
§

UrlsDropped

URLs dropped onto a window or widget (e.g. from an external browser or link drag).

Fields

§widget_id: WidgetId
§urls: Vec<String>
§offset: Option<usize>
§

TextDropped

Plain text dropped onto a window or widget.

Fields

§widget_id: WidgetId
§text: String
§offset: Option<usize>
§

DragSessionStarted

A text/custom-MIME drag session began on a configured source.

Fields

§widget_id: WidgetId
§

DragEntered

A drag session entered a configured target with compatible MIME kinds.

Fields

§target: WidgetId
§position: (i32, i32)
§offered: Vec<String>
§

DragMoved

The pointer moved over the current drag target.

Fields

§target: WidgetId
§position: (i32, i32)
§

DragExited

The pointer left a drag target before drop or cancellation.

Fields

§target: WidgetId
§

DragDropped

A payload was delivered to a compatible target and the session ended.

Fields

§target: WidgetId
§position: (i32, i32)
§payload: DragPayload
§effect: DropEffect
§

DragCancelled

A drag session ended without a compatible drop.

Fields

§

WindowResized

Fields

§widget_id: WidgetId
§width: i32
§height: i32
§

SplitPaneMoved

A split-pane backend reported a changed divider position. position is the first pane’s extent along the split axis; extent is the total extent along that axis.

Fields

§widget_id: WidgetId
§position: i32
§extent: i32
§

CloseRequested

An OS close request (the window’s X button, Alt+F4, the system menu) for a window with close interception enabled (Ui::set_close_guard). The window stays open until the app approves the close — typically after asking through Ui::show_confirm_dialog (GH-056).

Fields

§widget_id: WidgetId
§

WindowClosed

Fields

§widget_id: WidgetId
§

PopupDismissed

A transient popup session ended because of a user or window-system action.

Fields

§widget_id: WidgetId
§

TimerFired

A timer deadline was serviced on the UI event loop; elapsed is measured from the original start and missed counts coalesced ticks.

Fields

§timer: TimerId
§elapsed: Duration
§missed: u32
§

MotionTicked

Linear progress for a UI motion, derived from a coalesced timer deadline.

Fields

§motion: MotionId
§widget_id: WidgetId
§progress: f32
§

MotionFinished

A motion reached its duration and will not produce further ticks.

Fields

§motion: MotionId
§widget_id: WidgetId
§

PointerDown

Pointer input on a canvas widget.

Coordinate contract: x and y are logical (96-DPI) coordinates matching the space the layout engine lays the widget out in. A lane that receives physical pixels from the OS (Win32 under Per-Monitor v2) reports its display scale through crate::Backend::widget_scale_factor; crate::Ui inverts that scaling before dispatch, so app code hit-tests against the same coordinate space on every backend. Lanes that already receive logical coordinates (GTK4 gestures, Cocoa points, the Mock backend unless a display fixture installs a scale) report 1.0 and pass through untouched.

Fields

§widget_id: WidgetId
§button: u8
§

PointerMove

Pointer motion on a canvas widget; see UiEvent::PointerDown for the coordinate contract.

Fields

§widget_id: WidgetId
§

PointerUp

Pointer release on a canvas widget; see UiEvent::PointerDown for the coordinate contract.

Fields

§widget_id: WidgetId
§button: u8
§

KeyDown

Raw keyboard input on a focusable widget. key is the backend’s logical key name for the pressed key and is not layout- committed text: use UiEvent::Char for text input.

Ordering contract: for a stroke that produces text, KeyDown is reported before its UiEvent::Char and KeyUp after it. A stroke claimed by a menu accelerator reports UiEvent::MenuItemSelected instead and produces no KeyDown or Char; its KeyUp is still delivered so apps can clear pressed-key state.

Text-editing strokes are the accelerator exception: while a TextInput/TextArea holds focus, clipboard and undo commands (Ctrl+C/X/V/Z/Y/A), Delete, and Backspace stay with the control and never fire a registered accelerator — otherwise a rename field could not paste text while the app’s Paste command mirrors it. The exception matches GTK, where the focused widget processes those keys before application accelerators.

Fields

§widget_id: WidgetId
§ctrl: bool
§shift: bool
§alt: bool
§

KeyUp

Fields

§widget_id: WidgetId
§ctrl: bool
§shift: bool
§alt: bool
§

Char

Committed text input for a widget: direct keyboard input and IME commits both report through this event. text may contain more than one scalar (IME result strings, dead-key sequences).

Exactly one Char is reported per committed text. The commit may arrive without a preceding KeyDown (an IME candidate picked with the pointer) and is never interleaved with an unfinished IME composition — while a composition is active, text stays in UiEvent::CompositionChanged. Standard text controls report their value changes through UiEvent::TextChanged on top of the commit Char; backends observe the platform IME result for those controls (Win32 GCS_RESULTSTR, GTK’s widget input context), so apps do not need a separate text-input path per control.

Fields

§widget_id: WidgetId
§text: String
§

CompositionChanged

IME composition state changed for a widget.

Some(preedit) carries the live preedit string while a composition is active (it may be empty for a just-started composition); None marks the end of the composition exactly once, for both commits and cancels. Repeated preedit updates that report the same string are de-duplicated by the backend. A commit also reports UiEvent::Char with the committed text; the relative order of that Char and the ending None is platform-defined (Win32 commits before the end marker, GTK clears the preedit first), so apps must treat both signals independently instead of relying on their order.

Fields

§widget_id: WidgetId
§

FocusChanged

Keyboard focus moved to (focused: true) or away from (focused: false) a widget. Programmatic Ui::focus/Ui::focus_next/Ui::focus_previous report through this event, and native focus changes produce it; Ui keeps its focus record in sync from it.

Fields

§widget_id: WidgetId
§focused: bool
§

ThemeChanged

The OS light/dark preference changed.

Reported by backends whose Backend::theme_capabilities().change_events is true when the system setting transitions; the backend de-duplicates so the event only arrives on an actual mode change. It is informational: the active crate::Theme is unchanged until the app decides to follow the system (for example by calling Ui::set_theme_mode), and the current preference can always be re-read through Ui::system_theme_mode.

Fields

§high_contrast: bool
§

DisplayChanged

The window’s display metrics changed: a DPI or monitor transition was observed.

Reported by backends whose Backend::display_capabilities() has dpi_change_events true. The payload is a fresh DisplayInfo for the display the window is now on. Informational: apps decide whether to re-layout or re-query Ui::displays().

Fields

§display: DisplayInfo
§

TasksPending

Internal wake marker posted by a backend’s event-loop wake hook when background commands are queued (see Backend::wake_handle). Ui consumes it while draining and never returns it to application code.

§

Task(TaskEvent)

Background-task lifecycle notification posted through a UiProxy. See TaskEvent for the per-task payloads.

§

CalendarDateSelected

A date was selected in a calendar widget.

Fields

§widget_id: WidgetId
§selected_dates: Vec<CalendarDate>
§

CalendarMonthChanged

The visible month in a calendar widget changed.

Fields

§widget_id: WidgetId
§year: i32
§month: u32

Implementations§

Source§

impl UiEvent

Source

pub fn is_action(&self) -> bool

Whether this event is a deliberate user action on its widget.

Actions are the commit-style events an application normally answers with a message: a button click, a list/grid row activation, Enter in a text field, a checkbox toggle, a selection or value change, a link, toolbar tool, calendar date, or picker acceptance, and a finished inline grid edit. Incidental traffic — focus changes, raw key and pointer strokes, hover, live text edits, live picker previews, resizes, drags, and timers — is not an action.

Routes::on uses this filter so that, for example, a button that merely receives keyboard focus does not fire its message.

Trait Implementations§

Source§

impl Clone for UiEvent

Source§

fn clone(&self) -> Self

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

impl PartialEq for UiEvent

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for UiEvent

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.