Skip to main content

Widget

Trait Widget 

pub trait Widget {
Show 110 methods // Required methods fn build_layout( &mut self, taffy: &mut TaffyTree, theme: &Theme, node_map: &mut HashMap<NodeId, *mut dyn Widget>, ) -> NodeId; fn name(&self) -> &str; // Provided methods fn native_input_snapshot( &self, _state: &(dyn Any + 'static), _path: &(dyn Any + 'static), ) -> Option<Value> { ... } fn view_only_scroll(&self, _event: &WindowEvent) -> bool { ... } fn primary_vertical_scroll(&self) -> Option<PrimaryScrollRegion> { ... } fn apply_primary_vertical_scroll( &mut self, _action: PrimaryScrollAction, ) -> PrimaryScrollResult { ... } fn callback_binding(&self) -> Option<CallbackBinding> { ... } fn has_separate_document_owner(&self) -> bool { ... } fn history_owner(&self) -> Option<HistoryOwner> { ... } fn record_owners(&self) -> Vec<HistoryOwner> { ... } fn provide<'a>(&'a self, _request: &mut Request<'a, '_>) { ... } fn provide_mut<'a>(&'a mut self, _request: &mut RequestMut<'a, '_>) { ... } fn mount_native_views(&mut self, host: &NativeViewHost<'_>) { ... } fn unmount_native_views(&mut self) { ... } fn native_view_frame_start(&mut self) { ... } fn set_platform_conventions(&mut self, conventions: PlatformConventions) { ... } fn set_interaction_environment( &mut self, environment: InteractionEnvironment, ) { ... } fn sync(&mut self, state: &(dyn Any + 'static), path: &(dyn Any + 'static)) { ... } fn update( &mut self, state: &(dyn Any + 'static), path: &(dyn Any + 'static), ) -> bool { ... } fn settle(&mut self, edits: &mut Edits<'_>, path: &ExId) { ... } fn measure( &mut self, _known: Size<Option<f32>>, _available: Size<AvailableSpace>, _text_renderer: &mut TextRenderer, ) -> Size<f32> { ... } fn layout_info(&self) -> Option<LayoutInfo> { ... } fn adjust_layout_style( &mut self, _taffy: &mut TaffyTree, _node: NodeId, _text: &mut TextRenderer, ) -> bool { ... } fn apply_layout( &mut self, _taffy: &TaffyTree, _node: NodeId, _origin: Point, ) { ... } fn draw( &mut self, _scene: &mut Scene, _transform: Affine, _text_renderer: &mut TextRenderer, _theme: &Theme, _presence: &PresenceCtx, ) { ... } fn observe_physical_input(&mut self, _input: PhysicalInput) { ... } fn handle_event(&mut self, _event: &WindowEvent, _ctx: &mut EventCtx<'_>) { ... } fn children(&self) -> Vec<&dyn Widget> { ... } fn for_each_child(&self, visitor: &mut dyn FnMut(&dyn Widget)) { ... } fn children_mut(&mut self) -> Vec<&mut dyn Widget> { ... } fn local_resource_operation_handlers(&self) -> &'static [&'static str] { ... } fn resource_operation_handlers(&self) -> HashSet<String> { ... } fn test_id(&self) -> Option<&str> { ... } fn as_any(&self) -> Option<&(dyn Any + 'static)> { ... } fn as_any_mut(&mut self) -> Option<&mut (dyn Any + 'static)> { ... } fn reveal_descendant(&mut self, target: *const dyn Widget) -> bool { ... } fn test_rects(&self) -> Vec<(String, Rect)> { ... } fn get_rect(&self) -> Rect { ... } fn child_clip_rect(&self) -> Option<Rect> { ... } fn take_action_palette_request(&mut self) -> Option<ActionAddress> { ... } fn take_search_request(&mut self) -> bool { ... } fn cursor_shape(&self, _point: Point) -> Option<CursorIcon> { ... } fn claims_raw_touch(&self, _point: Point) -> bool { ... } fn tooltip(&self) -> Option<&str> { ... } fn tooltip_side(&self) -> TooltipSide { ... } fn tooltip_target_at(&self, point: Point) -> Option<(Rect, String)> { ... } fn is_focusable(&self) -> bool { ... } fn is_default_keyboard_focus(&self) -> bool { ... } fn keyboard_input_scope(&self) -> Option<u64> { ... } fn set_focus(&mut self, _focused: bool) { ... } fn set_invalid(&mut self, _invalid: bool) { ... } fn focus_requested(&mut self, target: Option<NodeId>, tree: &TaffyTree) { ... } fn is_focused(&self) -> bool { ... } fn wants_tab_input(&self) -> bool { ... } fn ime_cursor_rect(&self) -> Option<Rect> { ... } fn traps_focus(&self) -> bool { ... } fn accessibility(&self) -> Option<AccessNode> { ... } fn synthetic_accessibility_rect(&self, _path: &[usize]) -> Option<Rect> { ... } fn focus_synthetic_accessibility(&mut self, _path: &[usize]) -> bool { ... } fn accessibility_child_parent(&self, _child_index: usize) -> Option<usize> { ... } fn accessibility_child_path(&self, child_index: usize) -> Option<Vec<usize>> { ... } fn accessibility_represents_child(&self, _child_index: usize) -> bool { ... } fn perform_action( &mut self, _action: &Action, _key_path: &[u64], _state: &mut Edits<'_>, _path: &(dyn Any + 'static), ) -> bool { ... } fn perform_semantic_action( &mut self, target: &str, action: &Action, state: &mut Edits<'_>, path: &(dyn Any + 'static), ) -> bool { ... } fn is_enabled(&self) -> bool { ... } fn ime_requires_deferred_ack(&self) -> bool { ... } fn start_deferred_text(&mut self) -> Option<Receipt> { ... } fn commit_deferred_text(&mut self, text: &str) -> Option<Receipt> { ... } fn ime_purpose(&self) -> Option<ImePurpose> { ... } fn ime_multiline(&self) -> bool { ... } fn ime_edit_fingerprint(&self, key: &[u8; 32]) -> Option<[u8; 32]> { ... } fn presented(&self) -> bool { ... } fn opening(&self) -> bool { ... } fn text_review(&self) -> Option<(usize, String)> { ... } fn on_external_event( &mut self, _payload: &str, _state: &mut Edits<'_>, _root: &(dyn Any + 'static), ) { ... } fn on_nav_gesture( &mut self, dir: NavDirection, state: &(dyn Any + 'static), path: &(dyn Any + 'static), ) -> bool { ... } fn nav_availability(&self) -> NavAvailability { ... } fn take_focus_reset(&mut self) -> bool { ... } fn take_accessibility_request(&mut self) -> Option<AccessibilityRequest> { ... } fn dev_route(&self) -> Option<RouteSnapshot> { ... } fn restore_dev_route(&mut self, route: &RouteSnapshot) -> bool { ... } fn appearance_intent(&self) -> Option<AppearanceIntent> { ... } fn set_motion_reduced(&mut self, reduced: bool) { ... } fn needs_idle_sync(&self) -> bool { ... } fn take_committed_action(&mut self) -> Option<Vec<ChangeHash>> { ... } fn keeps_undo_step_open(&self) -> bool { ... } fn set_undo_status(&mut self, _status: &mut dyn FnMut() -> UndoStatus) { ... } fn take_undo_request(&mut self) -> Option<UndoRequest> { ... } fn handle_local_undo_request(&mut self, request: UndoRequest) -> bool { ... } fn apply_room_action( &mut self, _doc: &mut Edits<'_>, _type_id: &str, _payload: &[u8], ) -> bool { ... } fn start_operation( &mut self, op: &ResourceOperation<'_>, doc: &mut Edits<'_>, path: &ExId, ) -> Result<Option<ResourceOperationStart>, String> { ... } fn semantic_readers(&self) -> &'static [RegisteredSemanticReader] { ... } fn poll_resource_operation( &mut self, invocation: InvocationId, cancellation_requested: bool, doc: &AutoCommit, path: &ExId, ) -> Option<InvocationUpdate> { ... } fn wants_pointer_capture(&self) -> bool { ... } fn needs_animation_frame(&self) -> bool { ... } fn next_wake_deadline(&self) -> Option<Instant> { ... } fn modal_capture(&self) -> Option<Rect> { ... } fn take_structure_dirty(&mut self) -> bool { ... } fn take_structure_change(&mut self) -> StructureChange { ... } fn has_pending_visual_work(&self) -> bool { ... } fn has_transient_feedback(&self) -> bool { ... } fn needs_redraw(&self) -> bool { ... } fn collect_damage(&self, regions: &mut Vec<Rect>) { ... } fn damage_covers_own_box(&self) -> bool { ... } fn mark_drawn(&mut self) { ... } fn release_scene_cache(&mut self) { ... } fn is_layout_dirty(&self) -> bool { ... } fn layout_needs_measure(&self) -> bool { ... } fn paint_bounds(&self) -> Rect { ... } fn draw_overlay( &mut self, scene: &mut Scene, transform: Affine, text_renderer: &mut TextRenderer, theme: &Theme, presence: &PresenceCtx, ) { ... }
}

Required Methods§

fn build_layout( &mut self, taffy: &mut TaffyTree, theme: &Theme, node_map: &mut HashMap<NodeId, *mut dyn Widget>, ) -> NodeId

fn name(&self) -> &str

Provided Methods§

fn native_input_snapshot( &self, _state: &(dyn Any + 'static), _path: &(dyn Any + 'static), ) -> Option<Value>

Read-only state evidence for opt-in scheduled native input diagnostics. Called only around diagnostic inputs, never during ordinary input or paint. Keep this inexpensive and root-local; snapshots may be logged verbatim. This verifies widget state, not rendered pixels or display presentation.

fn view_only_scroll(&self, _event: &WindowEvent) -> bool

Opt in only when this wheel event changes scroll geometry and nothing else: no document edit, focus/selection, action availability, resource declaration, pending command or work that requires sync. The runner still lays out, paints and refreshes accessibility geometry. Unknown handlers stay on the full synchronization/publication path.

fn primary_vertical_scroll(&self) -> Option<PrimaryScrollRegion>

Explicit app-owned region; never search secondary children implicitly.

fn apply_primary_vertical_scroll( &mut self, _action: PrimaryScrollAction, ) -> PrimaryScrollResult

fn callback_binding(&self) -> Option<CallbackBinding>

Runtime binding inherited by descendants in a matching layout topology.

fn has_separate_document_owner(&self) -> bool

Whether this widget introduces a document owner distinct from the runner’s outer State. This is a compatibility check, never identity or authority for history access or restore.

A [Self::record_intent] alone does not qualify: the runner (or the enclosing TileHost, which reports its own binding) checks that record out as the very State this widget reads.

fn history_owner(&self) -> Option<HistoryOwner>

Opaque actual custody for framework History source registration.

fn record_owners(&self) -> Vec<HistoryOwner>

Records this widget keeps open beside the document it shows, each synced on its own route: a framework app’s records in the person’s own room (crate::record::person). They take no part in this widget’s history or controls.

fn provide<'a>(&'a self, _request: &mut Request<'a, '_>)

Answer a request for a capability this widget takes part in (see capability). Declare capabilities with crate::provides!.

fn provide_mut<'a>(&'a mut self, _request: &mut RequestMut<'a, '_>)

Exclusive counterpart to Widget::provide.

fn mount_native_views(&mut self, host: &NativeViewHost<'_>)

Attach native child views through this owner’s retained lifecycle topology.

Presentation containers with inactive or hidden live descendants override this traversal so lifecycle ownership remains independent of drawing and input visibility.

fn unmount_native_views(&mut self)

Tear native children down while their parent window still exists.

fn native_view_frame_start(&mut self)

Begin a native-view frame through this owner’s retained lifecycle topology.

fn set_platform_conventions(&mut self, conventions: PlatformConventions)

Receive host-selected platform conventions. The default propagates to retained children, keeping target-OS branches out of app code.

fn set_interaction_environment(&mut self, environment: InteractionEnvironment)

Receive the host’s current input capabilities. The default propagates through retained containers, so app code does not need device branches.

fn sync(&mut self, state: &(dyn Any + 'static), path: &(dyn Any + 'static))

Pull model state into this widget before layout. The default syncs the children Widget::children_mut returns; a widget overrides it only to read state of its own, or to sync children it does not expose there.

fn update( &mut self, state: &(dyn Any + 'static), path: &(dyn Any + 'static), ) -> bool

Notice, between frames, state that lives outside the document (a chrome revision, a momentum scroll still ticking) and report whether anything changed. The default updates every child Widget::children_mut returns, without short-circuiting, so a container never freezes its descendants at build-time state; a widget overrides it to check state of its own and then forward.

fn settle(&mut self, edits: &mut Edits<'_>, path: &ExId)

Apply, after the sync pass, what the widget took up there and must write: a worker’s answer, a chooser’s file, an event a child queued. Writes go only through typed actions on edits (a resource’s dispatcher); the host syncs again when the document changed. The default settles the children Widget::children_mut returns.

fn measure( &mut self, _known: Size<Option<f32>>, _available: Size<AvailableSpace>, _text_renderer: &mut TextRenderer, ) -> Size<f32>

fn layout_info(&self) -> Option<LayoutInfo>

Read-only resolved decisions for widgets with an explicit layout policy. None means the widget has no such policy; ordinary manual widgets remain valid. Values are available after build/settlement and carry real origins.

fn adjust_layout_style( &mut self, _taffy: &mut TaffyTree, _node: NodeId, _text: &mut TextRenderer, ) -> bool

Adjust this node’s style using its allocated size, before final geometry is applied. Return true only when the style changed (or an inherited decision child hooks read). An override may measure its owned children through ordinary references, entering their callback binding when present. Never reenter descendants through the raw node map while borrowing their parent, change topology, or build another layout tree. The shared host solver visits every registered widget, repeats layout at most eight times and skips a frame that does not settle.

fn apply_layout(&mut self, _taffy: &TaffyTree, _node: NodeId, _origin: Point)

Take the geometry layout gave this node. The default keeps none, for widgets that neither draw nor hit-test.

fn draw( &mut self, _scene: &mut Scene, _transform: Affine, _text_renderer: &mut TextRenderer, _theme: &Theme, _presence: &PresenceCtx, )

Paint into scene. The default paints nothing.

fn observe_physical_input(&mut self, _input: PhysicalInput)

Observe this app’s ordinary foreground physical input before framework shortcuts consume it. Keep feedback ephemeral; this is not an input grant.

fn handle_event(&mut self, _event: &WindowEvent, _ctx: &mut EventCtx<'_>)

Handle one input event with the runtime services for this retained node.

fn children(&self) -> Vec<&dyn Widget>

fn for_each_child(&self, visitor: &mut dyn FnMut(&dyn Widget))

Allocation-free read-only child traversal. Existing custom containers inherit a compatibility adapter over Self::children; toolkit containers override this to walk their retained storage directly.

fn children_mut(&mut self) -> Vec<&mut dyn Widget>

fn local_resource_operation_handlers(&self) -> &'static [&'static str]

Effect/view operation type ids this widget can actually dispatch.

Implementors of Self::start_operation must list their locally handled types here, beside it. The host combines these declarations across the retained tree and refuses to publish an action whose type has no handler, preventing a catalogue entry that can only fail at runtime.

fn resource_operation_handlers(&self) -> HashSet<String>

fn test_id(&self) -> Option<&str>

Stable id for the e2e test harness; None falls back to a path-based key. Must be unique across the live tree — the registry resolves on first match, so a duplicate shadows the second occurrence.

fn as_any(&self) -> Option<&(dyn Any + 'static)>

Downcast to the concrete widget, for hosts and tests that reach a known widget through dyn Widget. Default None (a widget may borrow and so not be 'static); a widget opts in with Some(self), and a Decorator answers itself.

fn as_any_mut(&mut self) -> Option<&mut (dyn Any + 'static)>

fn reveal_descendant(&mut self, target: *const dyn Widget) -> bool

Reveal a newly keyboard-focused descendant inside any enclosing viewport. Containers override this to scroll; ordinary widgets simply recurse toward the target and report whether it was found.

fn test_rects(&self) -> Vec<(String, Rect)>

Named hit rects for widgets that paint several affordances into one rect instead of composing children. Same space as Widget::get_rect; zero-area entries are dropped.

fn get_rect(&self) -> Rect

The rectangle this widget occupies. The default, for widgets that keep no geometry, is empty.

fn child_clip_rect(&self) -> Option<Rect>

Absolute logical clip applied to ordinary children during painting and pointer routing. Inspectors and enclosing scroll regions must respect this boundary instead of treating clipped descendants as visible extent.

fn take_action_palette_request(&mut self) -> Option<ActionAddress>

One-shot request to open the host’s action palette directly at a typed resource action. Parameter collection and permission checks remain host policy; widgets only name an address already present in resources().

fn take_search_request(&mut self) -> bool

One-shot request to open the host’s search palette, the same one the platform search shortcut opens. An app’s own search button latches it so search stays one shared host surface rather than an app overlay.

fn cursor_shape(&self, _point: Point) -> Option<CursorIcon>

point is logical coords, same space as Widget::get_rect; None defers to the default arrow. The host hit-tests the whole tree via node_map and picks the smallest-area claim, so containers need not override this.

fn claims_raw_touch(&self, _point: Point) -> bool

Opt out of touch-to-pointer emulation for contacts that begin at point (logical coords, same space as Widget::get_rect).

By default the host turns direct touch into pointer events: a tap clicks, a drag scrolls, a hold opens the context menu, and a second finger turns the contact into a pinch or pan. A widget that returns true here instead receives only the raw per-finger WindowEvent::Touch stream (Started/Moved/Ended/Cancelled, keyed by Touch::id, location in physical pixels) for every contact that begins inside it, and those contacts neither cancel nor are cancelled by other fingers. An on-screen keyboard uses this so two thumbs can type with overlapping presses.

Hit-tested like cursor_shape: the host asks every laid-out widget whose rect contains the point, so containers need not forward it.

fn tooltip(&self) -> Option<&str>

Revealed after a dwell over the widget’s rect, via the toolkit’s one tooltip mechanism (crate::widget::tooltip::TooltipHost), hit-tested like cursor_shape so containers need not forward it. An icon-only control should also use this as its accessible name.

fn tooltip_side(&self) -> TooltipSide

Which side of the control its tooltip goes: below by default, beside it for a control in a vertical rail.

fn tooltip_target_at(&self, point: Point) -> Option<(Rect, String)>

fn is_focusable(&self) -> bool

fn is_default_keyboard_focus(&self) -> bool

Preferred control when its app is explicitly activated without a valid saved control. Hosts still enforce visibility, enabled state and scope.

fn keyboard_input_scope(&self) -> Option<u64>

Exact app instance whose non-text shortcuts this subtree owns when activation has no control target. Unbound desktop chrome may declare the active tab; component boundaries default to their captured owner.

fn set_focus(&mut self, _focused: bool)

fn set_invalid(&mut self, _invalid: bool)

The form’s validation verdict for this control, set by Field::with_error: an invalid control edges itself in danger ink and reports invalid to assistive technology. Controls without a field face ignore it.

fn focus_requested(&mut self, target: Option<NodeId>, tree: &TaffyTree)

An explicit runner focus request, after resolving the actual keyboard owner. Retained flags and layout restoration are not user gestures. Containers can observe this to reveal the owning viewport.

fn is_focused(&self) -> bool

fn wants_tab_input(&self) -> bool

Whether a focused widget owns Tab instead of the host’s focus traversal. This is deliberately opt-in: ordinary form fields and controls retain platform-standard Tab/Shift+Tab navigation, while a code editor or terminal can receive the key for indentation or completion.

fn ime_cursor_rect(&self) -> Option<Rect>

Caret rectangle for the platform input method, in window-logical coordinates. Returning Some enables IME for the focused widget and positions its candidate window; non-text controls keep the default None and therefore disable IME.

fn traps_focus(&self) -> bool

While any widget answers true, the host restricts Tab/directional focus to this subtree (wrapping at the ends) and restores the prior focus once it goes back to false. Default false.

fn accessibility(&self) -> Option<AccessNode>

Role, name/description/value, and AccessState. Default None means presentational: the node is skipped and children reparent onto the parent. State must be derived, not stored so it can’t drift from draw; names must already be i18n!-resolved.

fn synthetic_accessibility_rect(&self, _path: &[usize]) -> Option<Rect>

Geometry for an immediate-mode semantic child from AccessNode::children. The path is its child-index path beneath this widget’s accessibility node. Returning a rect lets AccessKit activation inject the same click as pointer input.

fn focus_synthetic_accessibility(&mut self, _path: &[usize]) -> bool

Move this widget’s own immediate-mode focus to a synthetic semantic child. Retained widgets continue to use the ordinary taffy focus path.

fn accessibility_child_parent(&self, _child_index: usize) -> Option<usize>

Reparent one retained children entry beneath a synthetic child returned by accessibility. The returned index addresses AccessNode::children for this frame. Collections use this to place a real interactive row delegate inside its virtual ListItem/TreeItem instead of exporting a duplicate.

fn accessibility_child_path(&self, child_index: usize) -> Option<Vec<usize>>

Reparent one retained children entry beneath a nested path of synthetic children returned by accessibility.

The default preserves the one-level accessibility_child_parent contract. Tables override this to place a real cell control beneath its synthetic row and cell, for example [visible_row, column].

fn accessibility_represents_child(&self, _child_index: usize) -> bool

Whether one retained children entry is already represented in this widget’s own synthetic accessibility tree, so the bridge must not export it a second time. A host that publishes a child’s semantics itself (to add its own controls inside the same dialog) answers true for that child; assistive technology then sees one copy, not two.

fn perform_action( &mut self, _action: &Action, _key_path: &[u64], _state: &mut Edits<'_>, _path: &(dyn Any + 'static), ) -> bool

Perform an accessibility Action on this widget, or on one of its synthetic accessibility nodes. May mutate the CRDT like handle_event.

key_path names the target relative to this widget; empty means the widget itself. A widget that paints its own contents (a timeline of clips, a spreadsheet grid, a table of rows) has no child widgets to receive an action, so it describes its structure through AccessNode::children instead, and the host resolves an activated node back to (this widget, key path): one element per level of nesting — [row] for a table row, [row, cell] for a cell inside it. Each element is the node’s key, or its ordinal among its siblings when it declared none.

For an element keyed by identity rather than position, compare the incoming key against hash_key of your own id:

ⓘ
fn perform_action(&mut self, action: &Action, key_path: &[u64], ..) -> bool {
    let Some(&clip_key) = key_path.first() else { return false };
    let Some(clip) = self.clips.iter().find(|c| hash_key(&c.id) == clip_key) else {
        return false;   // stale reference — do nothing, never guess
    };
    ...
}

Returns true if the widget consumed the action. Default false (“not handled”) falls back to generic dispatch (Focus moves keyboard focus, Activate synthesises a click on the whole widget); widgets with richer semantics (slider inc/dec, combo expand/collapse, per-element canvases) override to handle those verbs precisely.

fn perform_semantic_action( &mut self, target: &str, action: &Action, state: &mut Edits<'_>, path: &(dyn Any + 'static), ) -> bool

Handle an action addressed to a synthetic accessibility child created by this widget. target is the opaque stable value supplied through AccessNode::with_action_target.

Custom canvases using AccessNode::with_keyed_action_routes do not need to override this method: the default decodes the published semantic target and forwards it to Widget::perform_action.

fn is_enabled(&self) -> bool

A disabled (false) widget is excluded from focus traversal, must reject input in handle_event, and renders dimmed (see DISABLED_ALPHA).

fn ime_requires_deferred_ack(&self) -> bool

This field needs a host that consumes deferred receipts. Ordinary native Wayland windows must not advertise it until they have that delivery path.

fn start_deferred_text(&mut self) -> Option<Receipt>

Begin one bounded deferred session after explicit host consent, preserving the existing original-field fingerprint. This grants no microphone access.

fn commit_deferred_text(&mut self, text: &str) -> Option<Receipt>

A private asynchronous final. None leaves ordinary synchronous IME dispatch to the host. A receipt binds this original field and must be acknowledged before the host releases its private recovery transcript.

fn ime_purpose(&self) -> Option<ImePurpose>

The focused widget wants platform text input (Wayland text-input-v3, native IMEs elsewhere). None is intentionally the default: enabling an IME for buttons, canvas tools or games makes the compositor raise an on-screen keyboard over content that cannot accept the committed text.

Winit currently exposes the protocol’s normal, password and terminal purposes. Widgets should return the closest truthful value; the compositor still receives the focus/enable/cursor lifecycle even when a more specialised purpose (email, URL, numeric) is unavailable at the toolkit boundary.

fn ime_multiline(&self) -> bool

Whether the original focused editor accepts line feeds as text. This is field policy, never inferred from a multiline accessibility presentation. Wrappers inherit only one unambiguous child at their active IME caret.

fn ime_edit_fingerprint(&self, key: &[u8; 32]) -> Option<[u8; 32]>

Opaque local invalidation of deferred input, including selection edits that leave the caret rectangle unchanged. The host supplies an ephemeral secret key; no text or selection is retained in the resulting digest. The default shares the accessibility door and excludes protected or read-only controls. Text controls can override it to avoid cloning text.

fn presented(&self) -> bool

Default true; the exception is a widget standing in for a process that has started but not drawn. Must latch: once true, never false again for the same content, or an un-presenting widget would make a window vanish mid-resize. What shows meanwhile is decided by Widget::opening.

fn opening(&self) -> bool

True once waiting long enough, while not yet presented, that showing nothing would read as broken. Delayed so a fast open never flashes an indicator.

fn text_review(&self) -> Option<(usize, String)>

(caret_byte, text), byte offset on a char boundary. The host diffs this before/after an event so caret-only moves (arrows, Home/End) get announced, not just typing.

fn on_external_event( &mut self, _payload: &str, _state: &mut Edits<'_>, _root: &(dyn Any + 'static), )

Delivers an out-of-band string payload from crate::app::UserEvent::External (e.g. a worker thread streaming output into a status log). Default no-op; the App redraws and re-syncs after dispatch, so mutating state here is enough.

fn on_nav_gesture( &mut self, dir: NavDirection, state: &(dyn Any + 'static), path: &(dyn Any + 'static), ) -> bool

Global back/forward gesture (swipe/edge-pull), recognised by crate::gesture::NavGestureRecognizer and delivered to the whole tree; return true once consumed. Default forwards to children, so a widget that owns history becomes swipe-navigable for free.

fn nav_availability(&self) -> NavAvailability

Which directions Self::on_nav_gesture would consume now. A widget that owns history overrides this beside on_nav_gesture.

fn take_focus_reset(&mut self) -> bool

One-shot (reading MUST clear it) signal to move focus to this subtree’s first focusable widget after the next rebuild. Only consulted under crate::app::App::autofocus_on_structure_change; a wizard raises it on step transitions.

fn take_accessibility_request(&mut self) -> Option<AccessibilityRequest>

One-shot (reading MUST clear it) request to change the window’s accessibility preferences, raised by a control the person used. The host applies it before the next frame. Default forwards the first request found among the children.

fn dev_route(&self) -> Option<RouteSnapshot>

Route history when this widget, or one it contains, is a Router.

Dev reload writes this beside the document so the same screen is showing after the process is replaced. Containers forward to the first child that has one. A Router reports its own stack and does not look inside the current screen.

fn restore_dev_route(&mut self, route: &RouteSnapshot) -> bool

Put route back. Returns whether a router in this subtree accepted it.

An unknown route name is refused and the existing screen stays up.

fn appearance_intent(&self) -> Option<AppearanceIntent>

Theme/high-contrast/reduced-motion/scale, polled under crate::app::App::appearance_reconcile — how a settings pane re-themes the running app live without a back-channel. Level-triggered; the App recurses Self::children itself, so containers need not forward it. First Some wins.

fn set_motion_reduced(&mut self, reduced: bool)

Apply the effective reduced-motion preference before the host asks this subtree whether it needs another animation frame. The default forwards recursively, making the preference a framework policy instead of an optional convention that every container has to remember to implement.

Custom-painted roots with app-local animation state should override this, settle any in-flight decorative transitions when reduced is true, and then forward to retained child widgets if they have any.

fn needs_idle_sync(&self) -> bool

Whether sync still needs to run on idle frames without input or collab events — e.g. waiting out a document-adoption grace window.

fn take_committed_action(&mut self) -> Option<Vec<ChangeHash>>

The affordance-driven twin of the Ctrl+K palette: when a widget’s own control dispatches the same tilo_actions action its ActionSpec exports, it reports the document heads captured just before here, so the host can record one undo boundary the same way a palette dispatch does. Rising-edge: reading MUST clear it.

fn keeps_undo_step_open(&self) -> bool

Whether the undo step this widget’s last reported boundary opened stays open for the actions that continue it — the rest of a word typed a keystroke at a time. A hosted component then closes the step at the widget’s next boundary, or before an undo, a save or a merge, instead of after this event. Answered by the widget itself, never its children.

fn set_undo_status(&mut self, _status: &mut dyn FnMut() -> UndoStatus)

Host → widget: the live state of the undo history, published once per frame to every laid-out widget.

A widget receives a read-only document or an Edits action loan, which carries the document but not its history — so without this a control could not tell whether there was anything to undo, and every app was reduced to printing the shortcut and hoping. Store the status (embed an UndoAccess) and read it back in draw, in is_enabled, and in accessibility — which only gets &self, and is exactly where the disabled state must be reflected.

The host sweeps its node_map, so this reaches a widget at any depth with no container forwarding. Call the provider only when the widget consumes status; deriving historical summaries can require a document diff. Default: ignore the provider without evaluating it.

fn take_undo_request(&mut self) -> Option<UndoRequest>

Widget → host: an undo or redo the user asked for.

The host drains this after each event and performs it through App::perform_undo / App::perform_redo — the same methods the Ctrl+Z key handler calls, so a button and the shortcut are one implementation and cannot drift.

Rising-edge: reading MUST clear it, so one activation is one undo. Default: nothing requested.

fn handle_local_undo_request(&mut self, request: UndoRequest) -> bool

Offer a host keyboard undo/redo shortcut to focused widget-local history before the application document consumes it.

The default recursively asks retained children. A component with its own editing history should return true only while focus is inside that component and it has consumed the request. Returning false preserves the standard collaboration-safe document undo behavior.

fn apply_room_action( &mut self, _doc: &mut Edits<'_>, _type_id: &str, _payload: &[u8], ) -> bool

Apply an action another app in this room published, if this app owns the document — lets an app address a document it doesn’t hold by saying what should happen instead of writing bytes directly, keeping each document to one writer. An unrecognised type_id is silently declined, not an error.

fn start_operation( &mut self, op: &ResourceOperation<'_>, doc: &mut Edits<'_>, path: &ExId, ) -> Result<Option<ResourceOperationStart>, String>

Admit an exported effect or view operation: the one entry every handler implements. Document operations never enter it.

Return Ok(None) to decline so routing continues; [ResourceOperationStart::Completed] with the output the action’s ActionContract promises when the work is done on return; or [ResourceOperationStart::Accepted] for work that later reports through Self::poll_resource_operation. Declare every handled type in Self::local_resource_operation_handlers.

Read the operation through [ResourceOperation::unscoped] unless the handler honours a required invocation’s custody; a custody-aware handler reads it through [ResourceOperation::with_custody], retains the scope with any job it starts and uses its checked callbacks at each later effect or document mutation. Hand operations a widget does not own to [start_in_children], which is also the default.

§Errors

Returns the first admission or synchronous-operation error.

fn semantic_readers(&self) -> &'static [RegisteredSemanticReader]

Inert immutable-reader registrations owned by this actual widget. Registration alone supplies no qualified owner frame or disclosure.

fn poll_resource_operation( &mut self, invocation: InvocationId, cancellation_requested: bool, doc: &AutoCommit, path: &ExId, ) -> Option<InvocationUpdate>

Poll one admitted operation without blocking the UI thread.

cancellation_requested is a cooperative signal from the action broker. Cancellable handlers should stop at a safe boundary and return Cancelled; non-cancellable handlers may ignore it. The default recursively polls retained children.

fn wants_pointer_capture(&self) -> bool

fn needs_animation_frame(&self) -> bool

App polls this in Event::AboutToWait; without it a curve would freeze partway until an unrelated event woke it again.

fn next_wake_deadline(&self) -> Option<Instant>

Earliest wall-clock deadline at which this subtree needs a sync/redraw even if there is no input. Unlike needs_animation_frame, this keeps the event loop asleep until the requested instant and is appropriate for filesystem/status polling rather than animation.

fn modal_capture(&self) -> Option<Rect>

Some(rect) when this subtree holds an open modal, its panel box. While any widget reports Some, the host suppresses its own global focus shortcuts and swallows unhandled pointer presses so nothing behind the modal is clickable. Containers MUST forward (the default does, via first Some among children).

fn take_structure_dirty(&mut self) -> bool

True if this subtree’s structural composition (children inserted/removed) changed since the last frame; the App rebuilds the taffy tree when so. Reading clears it. The default drains every retained child (no short-circuit, so no child keeps a stale flag) and reports whether any was dirty; a leaf has no children and reports false. A container that changes its own child list sets its own flag and ORs it with this traversal.

fn take_structure_change(&mut self) -> StructureChange

Self::take_structure_dirty, saying whether the frame’s damage can still describe the rebuild (StructureChange::Described). Reading clears what take_structure_dirty clears; the two must agree on whether there is a change. The default is the flag, as a StructureChange::Rebuild: only a widget that knows every pixel its change touches lands in its own damage says less, and a container forwards a child’s StructureChange::Described only by overriding this.

fn has_pending_visual_work(&self) -> bool

Work already requested by this view whose completion will replace a placeholder. Unlike animations, this can be awaited by still captures.

fn has_transient_feedback(&self) -> bool

Temporary feedback currently presented, such as a save acknowledgement. Captures may intentionally include it; scene-invariance checks can wait for it to disappear separately from unfinished placeholder work.

fn needs_redraw(&self) -> bool

Default true (dirty every frame). Opt into incremental redraw by tracking a dirty: bool, setting it in handle_event/sync, and clearing it in mark_drawn(). Containers MUST forward: dirty iff any descendant is.

fn collect_damage(&self, regions: &mut Vec<Rect>)

Logical-pixel bounds whose visual output differs from the last frame.

The conservative default covers this widget’s complete layout box. Pure layout containers should override this and union descendant damage so a small animated leaf does not force a full-window raster. Callers add an anti-alias/effect safety margin and fall back to a full redraw for layout, structure, overlays, or invalid retained targets.

fn damage_covers_own_box(&self) -> bool

Whether, after this frame’s draw, this widget’s own Self::collect_damage covers every pixel a relayout changed by moving or resizing its layout box: a host that repaints where moved widgets were and are may then leave this widget’s box to it (its children’s boxes still count). A block editor that grew by a paragraph says where its blocks were and are; the default does not claim it.

fn mark_drawn(&mut self)

Called after this widget’s scene lands in the composed frame, to clear a dirty flag. Default forwards to children.

fn release_scene_cache(&mut self)

Release retained encoded-scene storage in this subtree without marking its visual/model state dirty. Outer caches call this after a successful reuse: while the outer display list is authoritative, keeping byte-for-byte descendant encodings only duplicates memory. A later outer rebuild causes descendants to record/cache normally.

fn is_layout_dirty(&self) -> bool

Default true; widgets with a fixed intrinsic size should override to false unless a size-affecting mutation landed. Containers MUST forward: layout-dirty iff any descendant is.

fn layout_needs_measure(&self) -> bool

Whether a layout_dirty frame needs taffy to re-solve sizes (compute_layout) rather than just reposition already-solved boxes. Scrollable is the motivating override: it translates its origin in apply_layout without changing any taffy size, so re-solving on every scroll frame is pure waste.

fn paint_bounds(&self) -> Rect

Everything this widget paints, children included; draw_child skips the draw when it misses the viewport. Override for widgets that paint past their own rect.

fn draw_overlay( &mut self, scene: &mut Scene, transform: Affine, text_renderer: &mut TextRenderer, theme: &Theme, presence: &PresenceCtx, )

Top-layer pass, run once after the whole draw recursion, so anything emitted here composites above every sibling regardless of tree order — the toolkit’s overlay mechanism for content that escapes its layout box (an open Dropdown, a popover). Default recurses children_mut.

Implementors§

§

impl Widget for EmbeddedApp

§

impl Widget for BarGauge

§

impl Widget for CandlestickChart

§

impl Widget for CartesianPlot

§

impl Widget for CategoryChart

§

impl Widget for Chart

§

impl Widget for ChordChart

§

impl Widget for DistributionChart

§

impl Widget for FunnelChart

§

impl Widget for Heatmap

§

impl Widget for PieChart

§

impl Widget for PolarAreaChart

§

impl Widget for RadarChart

§

impl Widget for RangeChart

§

impl Widget for SankeyChart

§

impl Widget for Sparkline

§

impl Widget for SunburstChart

§

impl Widget for Treemap

§

impl Widget for HistoryHost

§

impl Widget for StandaloneHistoryPane

§

impl Widget for ActionPalette

§

impl Widget for ActivityTimeline

§

impl Widget for Card

§

impl Widget for CardGrid

§

impl Widget for CommandPalette

§

impl Widget for EditableLabel

§

impl Widget for KeyboardMap

§

impl Widget for LiveUi

§

impl Widget for NativeView

§

impl Widget for NavShell

§

impl Widget for Router

§

impl Widget for Section

§

impl Widget for UiGraphEditor

§

impl Widget for AcknowledgementLayer

§

impl Widget for DisplayArrangement

§

impl Widget for NoContent

§

impl Widget for Absent

§

impl Widget for Actions

§

impl Widget for Autocomplete

§

impl Widget for Avatar

§

impl Widget for Badge

§

impl Widget for BlockEditor

§

impl Widget for Breadcrumb

§

impl Widget for CaptureStudio

§

impl Widget for Chip

§

impl Widget for CodeEditor

§

impl Widget for ColorPicker

§

impl Widget for ColorSwatchPicker

§

impl Widget for Columns

§

impl Widget for ContextMenu

§

impl Widget for DatePicker

§

impl Widget for Divider

§

impl Widget for DocumentViewport

§

impl Widget for DropZone

§

impl Widget for Field

§

impl Widget for FilePicker

§

impl Widget for Form

§

impl Widget for FormPage

§

impl Widget for FormSection

§

impl Widget for GraphCanvas

§

impl Widget for GroupRow

§

impl Widget for IconWidget

§

impl Widget for Image

§

impl Widget for ImageCropEditor

§

impl Widget for ImageViewer

§

impl Widget for InputHint

§

impl Widget for ListRow

§

impl Widget for Manual

§

impl Widget for MediaCard

§

impl Widget for MediaGrid

§

impl Widget for ObjectHeader

§

impl Widget for Page

§

impl Widget for PagePreview

§

impl Widget for PageSidebar

§

impl Widget for PermissionPrompt

§

impl Widget for PopoverPrompt

§

impl Widget for ProgressBar

§

impl Widget for ProgressRing

§

impl Widget for PromptBody

§

impl Widget for PropertyList

§

impl Widget for PropertyValue

§

impl Widget for ResizeHandle

§

impl Widget for RichTextLine

§

impl Widget for ScreenshotMarkup

§

impl Widget for ShortcutRecorder

§

impl Widget for Skeleton

§

impl Widget for SplitHandle

§

impl Widget for StatGroup

§

impl Widget for StatTile

§

impl Widget for StatusLine

§

impl Widget for Stepper

§

impl Widget for StripView

§

impl Widget for TabBar

§

impl Widget for Table

§

impl Widget for TileHost

§

impl Widget for TimePicker

§

impl Widget for ToggleGroup

§

impl Widget for Toolbar

§

impl Widget for Tooltip

§

impl Widget for UndoButton

§

impl Widget for VideoPlayer

§

impl Widget for WebView

§

impl Widget for WindowGroup

§

impl Widget for WorkspaceView

§

impl Widget for ToastStack

§

impl Widget for ResourceActionHost

§

impl Widget for Banner

§

impl Widget for Button

§

impl Widget for Checkbox

§

impl Widget for Column

§

impl Widget for Container

§

impl Widget for Dropdown

§

impl Widget for EmptyState

§

impl Widget for Filtered

§

impl Widget for FindBar

§

impl Widget for FindScope

§

impl Widget for NumberInput

§

impl Widget for QrWidget

§

impl Widget for Row

§

impl Widget for Scrollable

§

impl Widget for SearchField

§

impl Widget for SearchResultsView

§

impl Widget for Slider

§

impl Widget for Spacer

§

impl Widget for Spinner

§

impl Widget for Stack

§

impl Widget for Text

§

impl Widget for TextInput

§

impl Widget for Toggle

§

impl<C> Widget for FloatingWindow<C>
where C: Widget + 'static,

§

impl<C> Widget for ModalDialog<C>
where C: Widget + 'static,

§

impl<C> Widget for Popover<C>
where C: Widget + 'static,

§

impl<C> Widget for PopoverButton<C>
where C: Widget + 'static,

§

impl<K> Widget for ModelView<K>
where K: PartialEq + 'static,

§

impl<L, R> Widget for ResizableSplit<L, R>
where L: Widget + 'static, R: Widget + 'static,

§

impl<M> Widget for VirtualList<M>
where M: ListModel + 'static,

Source§

impl<R: Resource> Widget for Each<R>

§

impl<Row> Widget for DataTable<Row>
where Row: 'static,

§

impl<T> Widget for FilterMenu<T>
where T: Clone + 'static,

§

impl<T> Widget for T
where T: Decorator,

Every decorator is a widget: each method is the decorator’s own, which forwards to the inner widget unless the decorator overrides it.

§

impl<T, M> Widget for TreeView<T, M>
where T: 'static, M: TreeModel + 'static,