pub enum InputEvent {
Pointer(PointerEvent),
PointerContact {
pointer_id: PointerId,
event: PointerEvent,
},
Scroll {
position: Point,
delta: ScrollDelta,
},
Scale(ScaleEvent),
Key(KeyEvent),
Ime(ImeEvent),
EditCommand(EditCommand),
Housekeeping,
Overlay(OverlayEvent),
FileDrop(FileDropEvent),
Shortcut(ShortcutId),
}Expand description
An input event delivered to the widget tree. Pointer, scroll, scale and file-drop events are hit-tested; key, IME and edit-command events are focus-routed; the rest are broadcasts.
Variants§
Pointer(PointerEvent)
A pointer gesture event — the only pointer form a widget receives; from a shell, the mouse.
PointerContact
One identified pointer contact from a shell. Widgets never receive it: the root dispatches
event as InputEvent::Pointer and reports pointer_id via EventCtx::pointer_id.
§Multi-contact contract
- (a) With no live capture, slot
0is hit-tested exactly likePointer; a capture taken on itsDownlatches this id as the gesture’s claimant. - (b) With no live capture, slot
1and above is dropped at the root. - (c) While a capture is live, the claimant’s events take the captured path; any other
id reaches only the captor (enclosing containers forward it unhandled), and only if it
called
EventCtx::capture_contactson its capturingDown; otherwise it is dropped. Only the claimant’sUp/Cancelreleases the capture, and a container takeover (EventCtx::release_captured_child) ends the opt-in.
Scroll
A scroll event at position carrying delta.
Fields
delta: ScrollDeltaScale(ScaleEvent)
A pinch/zoom event, hit-tested by ScaleEvent::focal and bubbling until handled.
Key(KeyEvent)
A keyboard key event, routed down the focus path.
Ime(ImeEvent)
An IME event, routed down the focus path.
EditCommand(EditCommand)
A decoded clipboard/selection command, routed down the focus path; with nothing focused it is dropped, so a shell may answer a stale paste request unconditionally.
Housekeeping
Not user input: a broadcast, never consumed, that lets a widget run a callback it queued
needing &mut State during a state-free build pass, on the frame that queued it.
Overlay(OverlayEvent)
A floated overlay surface’s own input: a broadcast only the owner holding the matching
OverlayKey acts on; every other widget ignores it.
FileDrop(FileDropEvent)
A desktop OS file drag; see FileDropEvent. Not routed through the overlay pre-pass.
Shortcut(ShortcutId)
A broadcast naming the shortcut a key pressed (crate::shortcuts); the declarer answers.
Implementations§
Source§impl InputEvent
impl InputEvent
Sourcepub fn position(&self) -> Point
pub fn position(&self) -> Point
The event’s location in the receiving widget’s local space; Point::ZERO for
focus-routed events and broadcasts, which callers must never hit-test on.
Sourcepub fn translated(&self, offset: Vec2) -> InputEvent
pub fn translated(&self, offset: Vec2) -> InputEvent
A copy with its position shifted by offset (a container passes -child_origin).
Positionless events and the window-space Overlay payload are returned unchanged.
Sourcepub fn transformed(&self, affine: &Affine) -> InputEvent
pub fn transformed(&self, affine: &Affine) -> InputEvent
A copy with exactly the positions translated shifts mapped through affine (the inverse
of the child’s transform); deltas and velocities are carried over as-is.
Sourcepub fn is_focus_routed(&self) -> bool
pub fn is_focus_routed(&self) -> bool
Whether this event is focus-routed (key, IME, edit command) rather than hit-tested.
Sourcepub fn is_broadcast(&self) -> bool
pub fn is_broadcast(&self) -> bool
Whether this event is a broadcast — Housekeeping, Overlay, Shortcut, or a file drop’s
Ended — forwarded to every child before any capture/focus/hit-test branch.