Skip to main content

SemanticsNode

Struct SemanticsNode 

Source
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: Rect

Where the node lies in the root’s coordinates: its layout rect, before graphics-layer transforms, as LayoutBox::rect holds it.

§placement: SemanticsPlacement

Where 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: u32

Incarnation of the runtime node, incremented when its storage is recycled.

§role: SemanticsRole

Where 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: bool§hidden: bool

Whether a screen reader skips this node and everything under it.

§merge_descendants: bool

Whether a screen reader takes this node and the text under it as one stop.

§traversal_index: f32

Where a screen reader visits this node among the ones beside it.

§text: Option<String>

The text an editable field holds.

§focusable: bool

Whether this node registered a focus target, so focus can land on it. Compose’s SemanticsProperties.Focused companion.

§focused: bool

Whether 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

Source

pub fn details(&self) -> &SemanticsDetails

The properties few nodes set, with nothing set for a node that holds none.

Source

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.

Source

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

Source

pub fn merges_accessibility_descendants(&self) -> bool

Whether this node combines its static descendants into one reader stop. Independently operable descendants remain separate stops.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for SemanticsNode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SemanticsNode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SemanticsNode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SemanticsNode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SemanticsNode

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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.