Skip to main content

WidgetNode

Struct WidgetNode 

Source
pub struct WidgetNode {
Show 13 fields pub widget: Box<dyn Widget>, pub parent: Option<WidgetId>, pub children: Vec<WidgetId>, pub activation: ActivationState, pub dirty: DirtyFlags, pub bounds: Rect, pub clips_children: bool, pub ime: Option<ImeContext>, pub event_pass_through: bool, pub gesture_dead_zone: bool, pub keyboard_capture: bool, pub hit_transparent: bool, pub last_painted_epoch: u64, /* private fields */
}
Expand description

A node in the widget arena storing a widget and its metadata.

Fields§

§widget: Box<dyn Widget>§parent: Option<WidgetId>§children: Vec<WidgetId>§activation: ActivationState§dirty: DirtyFlags§bounds: Rect§clips_children: bool

When true, the paint pass clips child rendering to this widget’s bounds. Set by scroll areas and overflow-hidden containers.

§ime: Option<ImeContext>

Optional OS input-method (IME) descriptor. Some(..) declares this node a text-input surface — the platform enables the OS IME (with the descriptor’s purpose) while the node is focused. None (the default) means no OS IME: enabling IME changes how text arrives, so the safe common-case default is off. The platform reads the focused node’s descriptor at focus-change time. See crate::ime.

§event_pass_through: bool

When true, hit-testing skips this node — pointer events fall through to whatever sits behind it. Descendants are still hit-tested normally (the recursion walks into children before the pass-through check), so an interactive subtree under a pass-through wrapper stays usable. Used by the debug inspector’s HighlightLayer and HoverProbe to paint over the user’s content without absorbing clicks. Default false.

§gesture_dead_zone: bool

When true, a pointer press anywhere in this widget’s subtree must NOT arm a drag/swipe recognizer on any ancestor above this node — the subtree is a gesture dead zone for ancestor gestures. Used so interactive controls (buttons, a menu) placed inside a draggable / swipeable container (a dock-panel header, a card, a list row) can be clicked without a few px of pointer jitter starting the ancestor’s drag. The boundary is honored by arm_drag_observers. Mirrors Electron’s -webkit-app-region: no-drag. Default false. See the DeadZone wrapper widget.

§keyboard_capture: bool

When true and this widget holds keyboard focus, a KeyDown is delivered straight to it without first running shortcut → intent → action resolution. The node is a keyboard capture surface: it wants every keystroke (including chords the host app binds as Shortcuts — Ctrl+C, Ctrl+W, Alt+<letter>, …). Used by a terminal emulator (which must forward Ctrl+C to the child process, not trigger the app’s copy shortcut), a game viewport, or a vim-mode editor. Honored by dispatch_event_impl, which skips the shortcut block for a focused capture node.

Ctrl+Tab / Ctrl+Shift+Tab are reserved: dispatch_event_impl cycles focus on that chord before dispatching to a focused capture node, so no capture surface can trap the keyboard (WCAG 2.1.2). Escape is not reserved — overlay back-navigation runs ahead of the check only while an overlay is open, so a capture surface below no overlay does see Escape. Default false.

§hit_transparent: bool

When true, this widget AND its entire subtree are invisible to hit-testing: the recursion returns immediately without descending into children, so the point falls through to whatever sits behind. Unlike event_pass_through (which is per-node — descendants stay hittable), this excludes the whole subtree. Use for purely decorative overlays whose children are themselves widgets — a count badge over a button, a watermark, a status dot — so they never steal clicks meant for the control underneath. Default false.

§last_painted_epoch: u64

The WidgetTree::paint_epoch at which this widget’s bounds were last observed inside the window viewport by the paint pass. The animation scheduler uses this to pause looping animations for offscreen widgets: an animation whose last_painted_epoch + 1 < tree.paint_epoch is considered off-screen and skipped. 0 means “not yet painted” — treated as “always visible” to keep headless tests (no render() call) from regressing.

Trait Implementations§

Source§

impl Debug for WidgetNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.