pub struct SemanticsNode {Show 20 fields
pub node_id: NodeId,
pub bounds: Rect,
pub placement: SemanticsPlacement,
pub node_generation: u32,
pub role: SemanticsRole,
pub widget_role: Option<SemanticsWidgetRole>,
pub actions: Vec<SemanticsAction>,
pub children: Vec<SemanticsNode>,
pub description: Option<String>,
pub on_click: Option<SemanticsCustomAction>,
pub selected: Option<bool>,
pub toggled: Option<bool>,
pub enabled: bool,
pub hidden: bool,
pub merge_descendants: bool,
pub traversal_index: f32,
pub text: Option<String>,
pub focusable: bool,
pub focused: bool,
pub details: Option<Box<SemanticsDetails>>,
}Expand description
A single node within the semantics tree.
Not Eq: a node now carries drawn-control bounds, which are floats. The
tree is compared for “did anything a screen reader can see change”, and
that comparison is PartialEq everywhere else on the accessibility path
(AccessibilityRect, AccessibilityElement) for the same reason.
Fields§
§node_id: NodeId§bounds: RectWhere the node lies in the root’s coordinates: its layout rect,
before graphics-layer transforms, as LayoutBox::rect holds it.
placement: SemanticsPlacementWhere layout put the node inside its parent’s content, from which a tree update moves a node that did not change along with its parent.
node_generation: u32Incarnation of the runtime node, incremented when its storage is recycled.
role: SemanticsRoleWhere this node sits in the tree (layout, text, subcomposition …).
widget_role: Option<SemanticsWidgetRole>What kind of control this node is, as a screen reader announces it —
Compose’s Role. Separate from SemanticsNode::role because a
clickable Row is structurally a layout node and semantically a button.
actions: Vec<SemanticsAction>§children: Vec<SemanticsNode>§description: Option<String>§on_click: Option<SemanticsCustomAction>Direct activation callback for keyboard and assistive technology.
selected: Option<bool>§toggled: Option<bool>§enabled: boolWhether a screen reader skips this node and everything under it.
merge_descendants: boolWhether a screen reader takes this node and the text under it as one stop.
traversal_index: f32Where a screen reader visits this node among the ones beside it.
text: Option<String>The text an editable field holds.
focusable: boolWhether this node registered a focus target, so focus can land on it.
Compose’s SemanticsProperties.Focused companion.
focused: boolWhether focus sits on this node right now.
details: Option<Box<SemanticsDetails>>The properties few nodes set, held only when the node sets one: read
them through SemanticsNode::details and write them through
SemanticsNode::set_details.
Implementations§
Source§impl SemanticsNode
impl SemanticsNode
Sourcepub fn details(&self) -> &SemanticsDetails
pub fn details(&self) -> &SemanticsDetails
The properties few nodes set, with nothing set for a node that holds none.
Sourcepub fn set_details(&mut self, details: SemanticsDetails)
pub fn set_details(&mut self, details: SemanticsDetails)
Replaces the node’s details. A node holds them only when something is set, and keeps the space it already held for them.
Sourcepub fn update_details(&mut self, update: impl FnOnce(&mut SemanticsDetails))
pub fn update_details(&mut self, update: impl FnOnce(&mut SemanticsDetails))
Changes some of the node’s details in place, through
SemanticsNode::set_details.
Source§impl SemanticsNode
impl SemanticsNode
Sourcepub fn merges_accessibility_descendants(&self) -> bool
pub fn merges_accessibility_descendants(&self) -> bool
Whether this node combines its static descendants into one reader stop. Independently operable descendants remain separate stops.
Sourcepub fn is_accessibility_boundary(&self) -> bool
pub fn is_accessibility_boundary(&self) -> bool
Whether an ancestor must leave this node and its content as a separate reader stop or container instead of including it in its own label.
Sourcepub fn accessibility_children(&self) -> impl Iterator<Item = &Self> + '_
pub fn accessibility_children(&self) -> impl Iterator<Item = &Self> + '_
Children in screen-reader order. Equal indices retain composition order; non-finite indices are treated as the default index, zero. Children that all keep the default index come in composition order without being collected first.
Sourcepub fn accessibility_label(&self) -> Option<Cow<'_, str>>
pub fn accessibility_label(&self) -> Option<Cow<'_, str>>
The accessible name, including merged static descendants in reading order. Hidden content and independent controls contribute no text to an ancestor. Password values never become names. An unnamed editable field returns an empty name so it remains reachable by assistive technology.
Sourcepub fn write_accessibility_label(&self, out: &mut String) -> bool
pub fn write_accessibility_label(&self, out: &mut String) -> bool
Appends the name SemanticsNode::accessibility_label gives to
out, without collecting a merged name first, and answers whether
the node has a name at all; an unnamed editable field has an empty one.