Expand description
§Events
Events are objects that say what happened, in plain terms, with named fields. They cover the pointer, keyboard, focus, widget semantics, lifecycle, window, time, the engine, and application-defined (custom) events.
Events flow through Pushrod much like the event buffer in GEM on the Atari ST:
SDL2 Event ──> WidgetCache ──> Widget::handle_event(&mut self, event, ctx)
│
ctx.emit(Clicked { .. })
│
v
event queue (Vec)
│
(after the Widget is no longer borrowed by the engine)
v
Engine callbacks: on_click / on_event
FnMut(&mut AppState, &mut Ui)Queueing the generated events, instead of calling application code from inside the Widget,
is what allows callbacks to receive mutable access to both the application state and every
Widget in the window without fighting the borrow checker.
Every Event has a kind (used by masks and the callback registry) and an
optional widget it concerns.
§Event reference
| Group | Event | Emitted when |
|---|---|---|
| Pointer | PointerEntered | The pointer moves onto a widget. |
| Pointer | PointerExited | The pointer moves off a widget. |
| Pointer | PointerMoved | The pointer moves; sent to the capturing widget, or the one under the pointer. |
| Pointer | PointerPressed | A mouse button goes down over a widget. |
| Pointer | PointerReleased | A mouse button goes up; sent to the widget that captured the press. |
| Pointer | Clicked | A widget (such as a button) was pressed and released on itself. |
| Pointer | Scrolled | The wheel or trackpad scrolls over a widget. |
| Keyboard | KeyPressed | A key goes down (or repeats) while a widget has the keyboard. |
| Keyboard | KeyReleased | A key goes up. |
| Keyboard | TextEntered | Text is typed (after input-method composition). |
| Focus | FocusGained | A widget becomes the keyboard focus. |
| Focus | FocusLost | A widget stops being the keyboard focus. |
| Semantic | Activated | A widget is activated (button, menu item, Return on a default action). |
| Semantic | Toggled | A checkable widget changes state; checked is the new state. |
| Semantic | ValueChanged | A slider, spinner, or similar changes value. |
| Semantic | SelectionChanged | The selection in a list, table, or tab set changes. |
| Semantic | TextChanged | The text of an editor changes. |
| Semantic | EditingFinished | An editor loses focus or the user confirms its text. |
| Semantic | Triggered | A named action is triggered (menu, shortcut, toolbar). |
| Semantic | ContextMenuRequested | The user asks for a context menu at position. |
| Semantic | PropertyChanged | A named property of a widget changes. |
| Semantic | ViewportChanged | A scrolling widget’s visible area moves to offset. |
| Lifecycle | Shown / Hidden | A widget becomes visible / hidden. |
| Lifecycle | Resized / Moved | A widget’s size / origin changes. |
| Lifecycle | Removed | A widget is removed from the tree. |
| Window | WindowResized | The window size changes. |
| Window | WindowFocusChanged | The window gains or loses focus. |
| Window | CloseRequested | The user asks to close the window. |
| Time | Tick | A frame passes while a widget animates; elapsed is the time since the last tick. |
| Engine | Engine | Pushrod performs an internal action (EngineEvent). |
| Extension | Custom | An application or library defines its own event (CustomEvent). |
BoundsChange from the first release is now PointerExited followed by PointerEntered,
and SystemEvent is split into PointerPressed, PointerReleased, and PointerMoved.
Window-system input arrives as a backend’s InputEvent.
Structs§
- Custom
Event - An application- or library-defined event, carried by
Event::Custom. - Event
Ctx - The context passed to
Widget::handle_event. - Event
Mask - A set of event classes, used to filter events for the run loop and for each
Widget.
Enums§
- Engine
Event - An action Pushrod performs internally, carried by
Event::Engine. - Engine
Event Kind - The kind of an
EngineEvent, without its data. Used to filter which engine events aWidgetor callback receives. - Event
- An event generated by Pushrod or by a
Widget. - Event
Kind - The kind of an
Event, without its data. Used by masks and the callback registry. - Event
Phase - The phase of delivery an input event is in when a
Widgetreceives it. - Event
Target - Where a
CustomEventis delivered. - Mask
Scope - What an event mask belongs to, in
EngineEvent::EventMaskChanged. - Propagation
- What a
Widgettells theWidgetCacheafter handling an input event: keep delivering it, or stop.
Functions§
- engine_
filter_ accepts - Returns whether an engine event passes an optional kind filter.