pub enum WidgetEvent {
Show 15 variants
PointerDown {
position: Point,
button: PointerButton,
modifiers: Modifiers,
},
PointerUp {
position: Point,
button: PointerButton,
modifiers: Modifiers,
},
PointerMove {
position: Point,
},
PointerEnter,
PointerLeave,
Scroll {
delta: ScrollDelta,
modifiers: Modifiers,
},
KeyDown {
key: Key,
modifiers: Modifiers,
text: Option<String>,
},
KeyUp {
key: Key,
modifiers: Modifiers,
},
ImeComposition {
text: String,
cursor: Option<Range<usize>>,
},
ImeCommit {
text: String,
},
FocusGained {
origin: FocusOrigin,
},
FocusLost,
AccessAction {
action: Action,
target: Option<WidgetId>,
target_node: NodeId,
data: Option<ActionData>,
},
ScrollIntoView {
target_bounds: Rect,
margin: f32,
align: ScrollAlign,
motion: ScrollMotion,
applied_scroll: Option<Arc<Mutex<Point>>>,
},
Gesture {
gesture: GestureEvent,
},
}Expand description
Events dispatched to widgets.
Variants§
PointerDown
PointerUp
PointerMove
PointerEnter
PointerLeave
Scroll
Fields
delta: ScrollDeltamodifiers: ModifiersModifier keys held at the time of the scroll event.
Defaults to Modifiers::NONE for synthesized events
(tests, keyboard-driven scroll requests). Real-platform
scroll events populate this from the platform’s tracked
modifier state — apps detect Ctrl-wheel-to-zoom by
inspecting modifiers.ctrl().
KeyDown
KeyUp
ImeComposition
ImeCommit
FocusGained
Fields
origin: FocusOriginFocusLost
AccessAction
Fields
target_node: NodeIdRaw AccessKit NodeId from the original ActionRequest.
May be a synthetic (widget-emitted child) NodeId — use
crate::accessibility::is_synthetic to distinguish it
from a widget-derived NodeId. The widget that registered
the parent (retrieved via tree.widget_for_synthetic)
is the one set in target.
data: Option<ActionData>Payload carried by the ActionRequest. For
Action::SetTextSelection this is
ActionData::SetTextSelection(TextSelection), for
Action::SetValue it’s ActionData::Value(Box<str>),
for scroll actions it carries scroll offsets, etc.
Widgets that declare these actions must read the payload
to honour screen-reader-initiated requests.
ScrollIntoView
Dispatched by the framework to a clipping ancestor when a child gains focus but is outside the viewport. The scroll area adjusts its offset to make the target bounds visible, with an optional margin around the target.
Fields
margin: f32Extra margin (in logical pixels) to keep around the target when scrolling it into view. Defaults to 0.0.
align: ScrollAlignWhere the target should end up on the scroll container’s
vertical axis. ScrollAlign::Minimal (the default, and what
every focus-driven reveal uses) only scrolls when the target is not
already fully visible; ScrollAlign::Fraction pins it to a
fixed height in the viewport whether or not it was already visible.
motion: ScrollMotionWhether the container should jump to the new offset or glide to it.
See ScrollMotion.
applied_scroll: Option<Arc<Mutex<Point>>>Optional back-channel for the handling scroll container to report
how far it actually scrolled ((dx, dy) in content pixels). When
several nested scroll containers must each reveal the same target,
the ancestor walk (scroll_rect_into_view) reads this after
dispatching to an inner container and shifts target_bounds by the
negated delta before asking the next (outer) one — so the outer sees
where the target will land once the inner’s (deferred) scroll
applies, not its pre-scroll position. None disables reporting (the
nested-reveal refinement is unavailable). A handler that ignores it
still works for the common single-container case.
Arc<Mutex<..>> (not Rc<Cell<..>>) so WidgetEvent stays Send
— some events are posted across threads. This one is only ever
touched on the dispatch thread, so the lock is always uncontended.
Gesture
A recognized gesture event, routed through the same preview/bubble system.
Fields
gesture: GestureEventTrait Implementations§
Source§impl Clone for WidgetEvent
impl Clone for WidgetEvent
Source§fn clone(&self) -> WidgetEvent
fn clone(&self) -> WidgetEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more