#[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
Clicked
Toggled
TextChanged
SelectionChanged
Fields
MultiSelectionChanged
Multi-select list/tree widgets report their selection set by row index.
GridCellClicked
A grid cell was clicked (DataGrid).
GridSelectionChanged
A range of cells was selected (DataGrid).
Fields
GridCellEditingStarted
In-place editing started on a cell.
GridCellEditingFinished
In-place editing finished on a cell.
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.
TextSubmitted
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.
SuggestionDismissed
The completion popup closed without acceptance: Escape,
blur, or a click elsewhere. Never follows a SuggestionSelected for
the same popup session.
ValueChanged
DateChanged
LinkActivated
ProgressChanged
MenuItemSelected
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.
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.
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.
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.
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.
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.
HelpRequested
The user asked for help from a picker dialog whose lane offers a help
affordance (capability font_dialog_help).
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.
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.
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.
ToolHovered
The pointer entered (Some) or left (None) a toolbar tool
(capability-gated: lanes that cannot report hot-item changes
never send it).
ToolContext
A toolbar tool was right-clicked, asking for a context menu.
DragStarted
A row drag began on a drag-enabled widget carrying the dragged row indices (usually the current selection).
Dropped
Rows were dropped onto target_index of the receiving widget; the
app performs the move through its core model and refreshes.
FilesDropped
External files were dropped onto a window or widget from the OS shell (e.g. Explorer, Finder, Nautilus).
UrlsDropped
URLs dropped onto a window or widget (e.g. from an external browser or link drag).
TextDropped
Plain text dropped onto a window or widget.
DragSessionStarted
A text/custom-MIME drag session began on a configured source.
DragEntered
A drag session entered a configured target with compatible MIME kinds.
DragMoved
The pointer moved over the current drag target.
DragExited
The pointer left a drag target before drop or cancellation.
DragDropped
A payload was delivered to a compatible target and the session ended.
DragCancelled
A drag session ended without a compatible drop.
WindowResized
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.
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).
WindowClosed
PopupDismissed
A transient popup session ended because of a user or window-system action.
TimerFired
A timer deadline was serviced on the UI event loop; elapsed is
measured from the original start and missed counts coalesced ticks.
MotionTicked
Linear progress for a UI motion, derived from a coalesced timer deadline.
MotionFinished
A motion reached its duration and will not produce further ticks.
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.
PointerMove
Pointer motion on a canvas widget; see UiEvent::PointerDown for the
coordinate contract.
PointerUp
Pointer release on a canvas widget; see UiEvent::PointerDown for
the coordinate contract.
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.
KeyUp
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.
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.
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.
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.
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: DisplayInfoTasksPending
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.
CalendarMonthChanged
The visible month in a calendar widget changed.
Implementations§
Source§impl UiEvent
impl UiEvent
Sourcepub fn is_action(&self) -> bool
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.