pub struct HandlerSet { /* private fields */ }Expand description
Temporary storage for handlers and metadata accumulated via builder
methods. Transferred to the WidgetNode during arena insertion.
Implementations§
Source§impl HandlerSet
impl HandlerSet
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty handler set for use in BuildContext::apply_self_handlers().
Sourcepub fn on_tap(
self,
f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_tap( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_tap handler. The closure receives a borrowed
TapEvent carrying the position in
widget-local coordinates, the finalising mouse button, and the
modifier state at that moment.
Default acceptance is ButtonMask::PRIMARY — left-click only.
Use accept_tap_buttons to widen
the set if you need right-click, middle-click, or auxiliary
buttons to fire this handler.
Sourcepub fn on_double_tap(
self,
f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_double_tap( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_double_tap handler. See on_tap for
the callback contract.
Sourcepub fn on_triple_tap(
self,
f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_triple_tap( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_triple_tap handler — fires on the third click within the
recognizer’s window (same 300 ms / 10 px defaults as double tap).
Runs independently of on_double_tap via cooperative gesture
recognizers (GestureRecognizer::resets_on_peer_recognition).
Sourcepub fn on_long_press(
self,
f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_long_press( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_long_press handler. The callback receives a borrowed
TapEvent whose modifiers are
captured from the held Down (since long-press recognises on a
timer before any Up).
Restrict (or extend) the set of pointer buttons that fire
on_tap. Default is ButtonMask::PRIMARY
(left-click only). Pass ButtonMask::ALL or
ButtonMask::PRIMARY | ButtonMask::SECONDARY, etc.
Restrict (or extend) the set of pointer buttons that fire
on_double_tap. Default
ButtonMask::PRIMARY.
Restrict (or extend) the set of pointer buttons that fire
on_triple_tap. Default
ButtonMask::PRIMARY.
Restrict (or extend) the set of pointer buttons that fire
on_long_press. Default
ButtonMask::PRIMARY.
Sourcepub fn on_hover(
self,
f: impl FnMut(bool, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_hover( self, f: impl FnMut(bool, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_hover handler.
Sourcepub fn on_key(
self,
f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static,
) -> Self
pub fn on_key( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> Self
Set the on_key handler.
Sourcepub fn on_key_preview(
self,
f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static,
) -> Self
pub fn on_key_preview( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> Self
Set the strict-ancestor key preview handler. Fires on every
ancestor of the focused widget (root → parent-of-target)
before the focused widget’s on_key runs. Return
EventResponse::Handled to consume the event.
Sourcepub fn on_drag(
self,
f: impl FnMut(DragPhase, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_drag( self, f: impl FnMut(DragPhase, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_drag handler (gesture-based drag). The closure receives
a DragPhase — Started, then zero or more Moved, then
Ended.
Sourcepub fn on_swipe(
self,
f: impl FnMut(SwipeDirection, f32, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_swipe( self, f: impl FnMut(SwipeDirection, f32, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_swipe handler. Fires once per swipe with the direction and velocity (pixels/second).
Sourcepub fn on_pinch(
self,
f: impl FnMut(PinchPhase, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_pinch( self, f: impl FnMut(PinchPhase, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_pinch handler. On desktop the phases are produced from
OS trackpad gestures (winit TouchpadMagnify / RotationGesture).
Sourcepub fn on_focus(
self,
f: impl FnMut(bool, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_focus( self, f: impl FnMut(bool, &mut EventContext<'_>) + 'static, ) -> Self
Set the on_focus handler. f is called with true on focus gain and
false on focus loss.
WCAG 3.2.1 (On Focus). Use this only to update local visual or
reactive state. Do NOT open a window, navigate, submit, or otherwise
change context from here: a context change triggered merely by a control
receiving focus is a Success Criterion 3.2.1 failure — keyboard users
tabbing through the UI would trigger it unexpectedly. (A debug-only guard
warns if ctx.open_window(...) / ctx.focus_window(...) is called from
inside focus dispatch.)
Sourcepub fn on_pointer_event(
self,
f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static,
) -> Self
pub fn on_pointer_event( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> Self
Set the on_pointer_event handler (low-level escape hatch).
Sourcepub fn on_scroll(
self,
f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static,
) -> Self
pub fn on_scroll( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> Self
Set the on_scroll handler.
Sourcepub fn on_access_action(
self,
f: impl FnMut(Action, &mut EventContext<'_>) -> EventResponse + 'static,
) -> Self
pub fn on_access_action( self, f: impl FnMut(Action, &mut EventContext<'_>) -> EventResponse + 'static, ) -> Self
Set the on_access_action handler.
Sourcepub fn on_access_action_request(
self,
f: impl FnMut(Action, NodeId, Option<ActionData>, &mut EventContext<'_>) -> EventResponse + 'static,
) -> Self
pub fn on_access_action_request( self, f: impl FnMut(Action, NodeId, Option<ActionData>, &mut EventContext<'_>) -> EventResponse + 'static, ) -> Self
Set the full AccessKit action-request handler. Receives the
action, target NodeId (may be a synthetic widget-emitted
child), and optional ActionData payload (e.g.
SetTextSelection(TextSelection) or Value(Box<str>)).
When this slot is set it’s called INSTEAD of
on_access_action for the same event.
Sourcepub fn cursor(self, cursor: CursorIcon) -> Self
pub fn cursor(self, cursor: CursorIcon) -> Self
Set the cursor icon.
Sourcepub fn clips_children(self, clips: bool) -> Self
pub fn clips_children(self, clips: bool) -> Self
Set the clips_children flag.
Sourcepub fn ime_input(self, ctx: ImeContext) -> Self
pub fn ime_input(self, ctx: ImeContext) -> Self
Declare this node a text-input surface, enabling the OS input method
(with ctx’s purpose) while it is focused. Leaving it unset (the
default) means no OS IME. The platform reads the focused node’s
descriptor at focus-change time. See crate::ime.
Sourcepub fn event_pass_through(self, pass_through: bool) -> Self
pub fn event_pass_through(self, pass_through: bool) -> Self
Make the widget invisible to pointer hit-testing. With
pass_through = true, pointer events traverse this node as if
it were not there — useful for purely decorative overlays that
must not absorb clicks (the debug inspector’s HighlightLayer
and HoverProbe use this).
Sourcepub fn gesture_dead_zone(self, dead_zone: bool) -> Self
pub fn gesture_dead_zone(self, dead_zone: bool) -> Self
Mark this widget’s subtree a gesture dead zone: a pointer press
inside it must not arm a drag/swipe recognizer on any ancestor above
it. Use to let interactive controls (buttons, a ⋮ menu) sit inside a
draggable / swipeable container (a dock-panel header, a card, a list
row) without a few px of click jitter starting the ancestor’s drag.
The container’s own drag still works everywhere else. Honored by
arm_drag_observers; see the DeadZone wrapper widget.
Sourcepub fn keyboard_capture(self, capture: bool) -> Self
pub fn keyboard_capture(self, capture: bool) -> Self
Mark this widget a keyboard capture surface: while it holds
focus, every KeyDown is delivered straight to its on_key
handler, bypassing shortcut → intent → action resolution. Use for
a terminal emulator that must forward Ctrl+C / Ctrl+W /
Alt+<letter> to a child process instead of triggering the host
app’s shortcuts, a game viewport, or a modal text surface.
§The escape contract
Ctrl+Tab / Ctrl+Shift+Tab are reserved and always move focus
out. The dispatcher cycles focus on that chord before the capture
node is consulted, so a capture surface cannot become a keyboard trap
(WCAG 2.1.2) however greedily its on_key behaves. Do not bind them.
Nothing else is reserved. In particular Escape is not: overlay
back-navigation runs first only while an overlay is actually open, so
a focused capture surface with no overlay above it does receive
Escape and may consume it. See
super::arena::WidgetNode::keyboard_capture.
Sourcepub fn hit_transparent(self, transparent: bool) -> Self
pub fn hit_transparent(self, transparent: bool) -> Self
Make this widget AND its whole subtree invisible to pointer
hit-testing. Stronger than event_pass_through:
that one keeps descendants hittable, this one excludes them too.
For purely decorative composite overlays (a count badge over a
button, a watermark) whose own children would otherwise swallow
the click meant for the control underneath.
Sourcepub fn focus_within(self, signal: Signal<bool>) -> Self
pub fn focus_within(self, signal: Signal<bool>) -> Self
Bind a user-owned Signal<bool> that the framework will set
to true whenever the focused widget is a strict descendant
of this node, and false otherwise. Useful for unified focus
halos around composite widgets (a chat composer that highlights
when its RichTextEditor or “Send” button is focused, a
Panel wrapping a SpinBox, etc).
Strict-ancestors only — a widget that is itself focused does
not also see its own focus_within signal flipped to true.
Combine with on_focus if you want both behaviours.
Sourcepub fn hover_within(self, signal: Signal<bool>) -> Self
pub fn hover_within(self, signal: Signal<bool>) -> Self
Bind a user-owned Signal<bool> that the framework will set
to true whenever the hovered widget is a strict descendant
of this node. Symmetric to focus_within.
Sourcepub fn visible_when(self, state: impl Into<Prop<bool>>) -> Self
pub fn visible_when(self, state: impl Into<Prop<bool>>) -> Self
Bind this node’s visibility to a bool / Signal<bool> / Prop<bool>.
A bound value shows/hides the node reactively (registered at
Relayout). Equivalent to ctx.visible_when(id, ..); exposed as a
builder method so teksu! can write visible_when: sig as a property.
Set a context-menu factory. See ContextMenuFactory for the
full contract: the closure receives the click position
(widget-local) and a full EventContext, and returns
Some(menu) to mount or None to decline (falling through to
the nearest ancestor with a factory).
Sourcepub fn on_drag_hover(
self,
f: impl FnMut(&DragPayload, Point, &mut EventContext<'_>) -> DropFeedback + 'static,
) -> Self
pub fn on_drag_hover( self, f: impl FnMut(&DragPayload, Point, &mut EventContext<'_>) -> DropFeedback + 'static, ) -> Self
Set the drag hover handler. Called when a drag payload hovers over this widget.
Return DropFeedback to indicate acceptance and visual feedback.
Sourcepub fn on_drag_leave(
self,
f: impl FnMut(&mut EventContext<'_>) + 'static,
) -> Self
pub fn on_drag_leave( self, f: impl FnMut(&mut EventContext<'_>) + 'static, ) -> Self
Set the drag-leave handler. Fires when a drag that was over this
widget moves to another target, completes (drop on any target), or
is cancelled. Widgets that stash transient feedback state in
on_drag_hover must clear it here.
Sourcepub fn on_drag_tick(
self,
f: impl FnMut(Point, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_drag_tick( self, f: impl FnMut(Point, &mut EventContext<'_>) + 'static, ) -> Self
Set the per-frame drag-tick handler. Fires once per frame while a drag is active and this widget is the current drop target. The closure receives the current pointer position in widget-local coordinates. Use for behaviours that must keep running even when the pointer is stationary — viewport-edge auto-scroll and spring-loaded folders.
Sourcepub fn on_drop(
self,
f: impl FnMut(DragPayload, Point, &mut EventContext<'_>) -> bool + 'static,
) -> Self
pub fn on_drop( self, f: impl FnMut(DragPayload, Point, &mut EventContext<'_>) -> bool + 'static, ) -> Self
Set the drop handler. Called when a payload is dropped on this widget.
Return true if the drop was accepted.
Sourcepub fn on_drag_ended(
self,
f: impl FnMut(DropOutcome, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_drag_ended( self, f: impl FnMut(DropOutcome, &mut EventContext<'_>) + 'static, ) -> Self
Set the drag-ended handler on a drag source. Fires when a drag
this widget started ends — dropped on an in-app target, exported to
another application via the OS (copy / move), or cancelled. Use it to
react to the outcome, e.g. remove the dragged item on a
DropOutcome::OsMove.