Skip to main content

Module event

Module event 

Source
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

GroupEventEmitted when
PointerPointerEnteredThe pointer moves onto a widget.
PointerPointerExitedThe pointer moves off a widget.
PointerPointerMovedThe pointer moves; sent to the capturing widget, or the one under the pointer.
PointerPointerPressedA mouse button goes down over a widget.
PointerPointerReleasedA mouse button goes up; sent to the widget that captured the press.
PointerClickedA widget (such as a button) was pressed and released on itself.
PointerScrolledThe wheel or trackpad scrolls over a widget.
KeyboardKeyPressedA key goes down (or repeats) while a widget has the keyboard.
KeyboardKeyReleasedA key goes up.
KeyboardTextEnteredText is typed (after input-method composition).
FocusFocusGainedA widget becomes the keyboard focus.
FocusFocusLostA widget stops being the keyboard focus.
SemanticActivatedA widget is activated (button, menu item, Return on a default action).
SemanticToggledA checkable widget changes state; checked is the new state.
SemanticValueChangedA slider, spinner, or similar changes value.
SemanticSelectionChangedThe selection in a list, table, or tab set changes.
SemanticTextChangedThe text of an editor changes.
SemanticEditingFinishedAn editor loses focus or the user confirms its text.
SemanticTriggeredA named action is triggered (menu, shortcut, toolbar).
SemanticContextMenuRequestedThe user asks for a context menu at position.
SemanticPropertyChangedA named property of a widget changes.
SemanticViewportChangedA scrolling widget’s visible area moves to offset.
LifecycleShown / HiddenA widget becomes visible / hidden.
LifecycleResized / MovedA widget’s size / origin changes.
LifecycleRemovedA widget is removed from the tree.
WindowWindowResizedThe window size changes.
WindowWindowFocusChangedThe window gains or loses focus.
WindowCloseRequestedThe user asks to close the window.
TimeTickA frame passes while a widget animates; elapsed is the time since the last tick.
EngineEnginePushrod performs an internal action (EngineEvent).
ExtensionCustomAn 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§

CustomEvent
An application- or library-defined event, carried by Event::Custom.
EventCtx
The context passed to Widget::handle_event.
EventMask
A set of event classes, used to filter events for the run loop and for each Widget.

Enums§

EngineEvent
An action Pushrod performs internally, carried by Event::Engine.
EngineEventKind
The kind of an EngineEvent, without its data. Used to filter which engine events a Widget or callback receives.
Event
An event generated by Pushrod or by a Widget.
EventKind
The kind of an Event, without its data. Used by masks and the callback registry.
EventPhase
The phase of delivery an input event is in when a Widget receives it.
EventTarget
Where a CustomEvent is delivered.
MaskScope
What an event mask belongs to, in EngineEvent::EventMaskChanged.
Propagation
What a Widget tells the WidgetCache after handling an input event: keep delivering it, or stop.

Functions§

engine_filter_accepts
Returns whether an engine event passes an optional kind filter.