Skip to main content

SemanticsNode

Struct SemanticsNode 

Source
pub struct SemanticsNode {
Show 45 fields pub node_id: NodeId, pub role: SemanticsRole, pub widget_role: Option<SemanticsWidgetRole>, pub actions: Vec<SemanticsAction>, pub children: Vec<SemanticsNode>, pub description: Option<String>, pub state_description: Option<String>, pub on_click_label: Option<String>, pub on_long_click: Option<SemanticsLongClick>, pub on_long_click_label: Option<String>, pub on_magic_tap: Option<SemanticsMagicTap>, pub on_magic_tap_label: Option<String>, pub input_labels: Vec<String>, pub language: Option<String>, pub selected: Option<bool>, pub toggled: Option<bool>, pub enabled: bool, pub custom_actions: Vec<SemanticsCustomAction>, pub canvas_children: Vec<CanvasSemanticsNode>, pub editable_text: bool, pub hidden: bool, pub is_modal: bool, pub merge_descendants: bool, pub selectable_group: bool, pub pane_title: Option<String>, pub error: Option<String>, pub password: bool, pub traversal_index: f32, pub text: Option<String>, pub text_selection: Option<TextRange>, pub focusable: bool, pub focused: bool, pub live_region: Option<LiveRegionMode>, pub progress: Option<ProgressBarRangeInfo>, pub set_progress: Option<SemanticsSetProgress>, pub set_text: Option<SemanticsSetText>, pub set_selection: Option<SemanticsSetSelection>, pub expand: Option<SemanticsExpand>, pub collapse: Option<SemanticsExpand>, pub dismiss: Option<SemanticsDismiss>, pub vertical_scroll: Option<ScrollAxisRange>, pub horizontal_scroll: Option<ScrollAxisRange>, pub scroll_by: Option<SemanticsScrollBy>, pub scroll_to_index: Option<SemanticsScrollToIndex>, pub collection: Option<CollectionInfo>,
}
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§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>§state_description: Option<String>§on_click_label: Option<String>§on_long_click: Option<SemanticsLongClick>

What this control does when a screen reader asks for its long press.

§on_long_click_label: Option<String>

What the long press does, as a verb phrase a reader reads out.

§on_magic_tap: Option<SemanticsMagicTap>

What this control does on VoiceOver’s magic tap.

§on_magic_tap_label: Option<String>

What the magic tap does, as a verb phrase a reader reads out.

§input_labels: Vec<String>

The short names a person says to Voice Control to reach this control.

§language: Option<String>

The language of this control’s text, as a BCP 47 tag.

§selected: Option<bool>§toggled: Option<bool>§enabled: bool§custom_actions: Vec<SemanticsCustomAction>§canvas_children: Vec<CanvasSemanticsNode>

Controls this node drew rather than laid out; their bounds are relative to this node’s own top-left. See CanvasSemanticsNode.

§editable_text: bool§hidden: bool

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

§is_modal: bool

Whether this subtree makes content outside it unavailable to assistive technology.

§merge_descendants: bool

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

§selectable_group: bool

Whether the selectable controls under this node form one group.

§pane_title: Option<String>

The title of the screen or pane this node is the root of.

§error: Option<String>

Why the control’s content is wrong, when it is.

§password: bool

Whether this field holds a secret, so its text stays unspoken.

§traversal_index: f32

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

§text: Option<String>

The text an editable field holds.

§text_selection: Option<TextRange>§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.

§live_region: Option<LiveRegionMode>

How urgently a screen reader reads this node when its text changes. Compose’s SemanticsProperties.LiveRegion.

§progress: Option<ProgressBarRangeInfo>

The value this control holds inside a range. Compose’s ProgressBarRangeInfo.

§set_progress: Option<SemanticsSetProgress>

What this control does when a screen reader moves its value.

§set_text: Option<SemanticsSetText>

What this field does when a screen reader hands it text.

§set_selection: Option<SemanticsSetSelection>

What this field does when a screen reader moves its caret or picks a stretch of its text.

§expand: Option<SemanticsExpand>

What this control does when a screen reader asks it to open.

§collapse: Option<SemanticsExpand>

What this control does when a screen reader asks it to close.

§dismiss: Option<SemanticsDismiss>

What this control does when a screen reader asks to send it away.

§vertical_scroll: Option<ScrollAxisRange>

How far this container scrolled up and down, when it scrolls.

§horizontal_scroll: Option<ScrollAxisRange>

How far this container scrolled left and right, when it scrolls.

§scroll_by: Option<SemanticsScrollBy>

What this container does when a screen reader pages it.

§scroll_to_index: Option<SemanticsScrollToIndex>

What this list does when a screen reader asks for the row at an index.

§collection: Option<CollectionInfo>

How many rows and columns this list holds, when it is a list.

Implementations§

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) -> Vec<&Self>

Children in screen-reader order. Equal indices retain composition order; non-finite indices are treated as the default index, zero.

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.

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.