Skip to main content

SemanticsData

Struct SemanticsData 

Source
pub struct SemanticsData {
Show 14 fields pub role: SemanticsRole, pub label: Option<String>, pub value: Option<String>, pub toggled: Option<bool>, pub expanded: Option<bool>, pub selected: Option<bool>, pub modal: bool, pub live: Option<LiveRegion>, pub virtual_items: Vec<VirtualSemanticItem>, pub enabled: bool, pub bounds: Rect, pub children: Vec<ElementId>, pub focusable: bool, pub numeric: Option<SemanticsNumericValue>,
}
Expand description

单个节点的语义快照(与 Element 1:1 关联)

runtime crate 从 ElementTree 遍历收集 Vec<(ElementId, SemanticsData), 然后翻译成 Vec<(accesskit::NodeId, accesskit::Node)> 构建 TreeUpdate。

bounds 单位:逻辑像素(同 Element.origin + RO layout size)。 runtime 在推送 TreeUpdate 前乘 DPR 转物理像素。

Fields§

§role: SemanticsRole

无障碍角色

§label: Option<String>

可读标签(SR 读取的文字,优先于子节点文字)

  • Button: 通常来自 .label TextWidget 的内容
  • TextInput: placeholder 或当前 value
  • 纯视觉节点: None(由子节点聚合)
§value: Option<String>

当前值(对有状态控件)

  • CheckBox → “checked” / “unchecked”
  • Slider → 0.0 ~ 1.0
  • TextInput → 输入文字
§toggled: Option<bool>

是否当前处于激活/选中状态(CheckBox checked, Slider enabled 等)

§expanded: Option<bool>

展开/收起状态(TreeItem / 折叠面板)

§selected: Option<bool>

列表项/Tab 选中状态

§modal: bool

是否模态对话框

§live: Option<LiveRegion>

动态内容播报级别(Toast 等)

§virtual_items: Vec<VirtualSemanticItem>

虚拟子项(单 RO 列表/菜单的行语义)

§enabled: bool

控件是否可交互(禁用状态时 SR 应告知用户)

§bounds: Rect

逻辑像素 bounds(位置 + 尺寸),runtime 乘 DPR 送 AccessKit

§children: Vec<ElementId>

子节点 ElementId 列表(用于构建无障碍树结构)

§focusable: bool

是否是焦点目标(默认 role 推断;显式覆盖)

§numeric: Option<SemanticsNumericValue>

数值控件的值域(Slider 等);runtime 转成 AccessKit 的 numeric_value 系列属性

Implementations§

Source§

impl SemanticsData

Source

pub fn children(&self) -> &[ElementId]

子节点 ElementId 列表(只读)。

Source

pub fn new(role: SemanticsRole, bounds: Rect) -> Self

最简构造:只给 role 和 bounds,其他用合理默认

Source

pub fn with_label(self, label: impl Into<String>) -> Self

Source

pub fn with_numeric_value( self, value: f64, min: f64, max: f64, step: f64, ) -> Self

Source

pub fn with_value(self, value: impl Into<String>) -> Self

Source

pub fn with_toggled(self, v: bool) -> Self

Source

pub fn with_expanded(self, expanded: bool) -> Self

Source

pub fn with_selected(self, selected: bool) -> Self

Source

pub fn with_modal(self, modal: bool) -> Self

Source

pub fn with_live(self, live: LiveRegion) -> Self

Source

pub fn with_children(self, children: Vec<ElementId>) -> Self

Trait Implementations§

Source§

impl Clone for SemanticsData

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 SemanticsData

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> 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> 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.