Skip to main content

SemanticsProperties

Struct SemanticsProperties 

Source
pub struct SemanticsProperties {
    pub role: Role,
    pub label: Option<String>,
    pub value: Option<String>,
    pub toggled: Toggled,
    pub clickable: bool,
    pub disabled: bool,
    pub range: Option<(f32, f32, f32)>,
}
Expand description

A widget’s resolved semantic annotation, for accessibility.

Fields§

§role: Role

The announced role.

§label: Option<String>

Accessible name (what the screen reader reads out).

§value: Option<String>

Textual value (a field’s contents, a slider’s position, and so on).

§toggled: Toggled

Checked state (checkboxes, switches, radios).

§clickable: bool

Actionable by click — the screen reader offers “activate”.

§disabled: bool

Disabled (greyed out, non-interactive).

§range: Option<(f32, f32, f32)>

Numeric bounds (min, value, max) for sliders and progress bars.

Implementations§

Source§

impl SemanticsProperties

Source

pub fn new(role: Role) -> SemanticsProperties

An annotation carrying the given role and nothing else.

Source

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

Sets the accessible name.

Source

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

Sets the textual value.

Source

pub fn toggled(self, on: bool) -> SemanticsProperties

Marks the checked state.

Source

pub fn maybe_toggled(self, on: Option<bool>) -> SemanticsProperties

Marks it on, off, or partly on — None being the third answer, not a missing one.

Source

pub fn clickable(self) -> SemanticsProperties

Marks the element as actionable.

Source

pub fn disabled(self, disabled: bool) -> SemanticsProperties

Marks the element as disabled.

Source

pub fn range(self, min: f32, value: f32, max: f32) -> SemanticsProperties

Sets the numeric bounds (min, value, max).

Source

pub fn is_meaningful(&self) -> bool

true when this node carries something useful to assistive technology — a non-null role or a label. Empty containers are left out of the tree.

Source

pub fn over(self, under: &SemanticsProperties) -> SemanticsProperties

This annotation laid over under, whose answers show through wherever this one said nothing.

What a container states about its child usually is not everything there is to say: something that marks a widget as a heading knows the role and has no idea what the words are. Dropping the child’s answer would replace a spoken title with silence, which is a worse outcome than the unlabelled heading it was fixing.

Two labels are joined, not chosen between — one line each, as the reference joins the labels of a merged subtree. A row holding a checkbox and its caption reads as one control with both, and picking one would drop the other on the floor with nothing to say which.

Every other field is this one’s answer, or the other’s where it had none, with each field’s “none” being its own: Role::None, Toggled::None, a false flag, an absent Option. clickable and disabled are unions rather than choices, because either one being true is a fact about the whole.

Trait Implementations§

Source§

impl Clone for SemanticsProperties

Source§

fn clone(&self) -> SemanticsProperties

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 SemanticsProperties

Source§

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

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

impl Default for SemanticsProperties

Source§

fn default() -> SemanticsProperties

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

impl PartialEq for SemanticsProperties

Source§

fn eq(&self, other: &SemanticsProperties) -> 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 SemanticsProperties

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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

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.