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.
Trait Implementations§
Source§impl Clone for InputEvent
impl Clone for InputEvent
Source§fn clone(&self) -> InputEvent
fn clone(&self) -> InputEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InputEvent
impl Debug for InputEvent
Source§impl PartialEq for InputEvent
impl PartialEq for InputEvent
impl StructuralPartialEq for InputEvent
Auto Trait Implementations§
impl Freeze for InputEvent
impl RefUnwindSafe for InputEvent
impl Send for InputEvent
impl Sync for InputEvent
impl Unpin for InputEvent
impl UnsafeUnpin for InputEvent
impl UnwindSafe for InputEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.