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: RoleThe 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: ToggledChecked state (checkboxes, switches, radios).
clickable: boolActionable by click — the screen reader offers “activate”.
disabled: boolDisabled (greyed out, non-interactive).
range: Option<(f32, f32, f32)>Numeric bounds (min, value, max) for sliders and progress bars.
Implementations§
Source§impl SemanticsProperties
impl SemanticsProperties
Sourcepub fn new(role: Role) -> SemanticsProperties
pub fn new(role: Role) -> SemanticsProperties
An annotation carrying the given role and nothing else.
Sourcepub fn label(self, label: impl Into<String>) -> SemanticsProperties
pub fn label(self, label: impl Into<String>) -> SemanticsProperties
Sets the accessible name.
Sourcepub fn value(self, value: impl Into<String>) -> SemanticsProperties
pub fn value(self, value: impl Into<String>) -> SemanticsProperties
Sets the textual value.
Sourcepub fn toggled(self, on: bool) -> SemanticsProperties
pub fn toggled(self, on: bool) -> SemanticsProperties
Marks the checked state.
Sourcepub fn maybe_toggled(self, on: Option<bool>) -> SemanticsProperties
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.
Sourcepub fn clickable(self) -> SemanticsProperties
pub fn clickable(self) -> SemanticsProperties
Marks the element as actionable.
Sourcepub fn disabled(self, disabled: bool) -> SemanticsProperties
pub fn disabled(self, disabled: bool) -> SemanticsProperties
Marks the element as disabled.
Sourcepub fn range(self, min: f32, value: f32, max: f32) -> SemanticsProperties
pub fn range(self, min: f32, value: f32, max: f32) -> SemanticsProperties
Sets the numeric bounds (min, value, max).
Sourcepub fn is_meaningful(&self) -> bool
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.
Sourcepub fn over(self, under: &SemanticsProperties) -> SemanticsProperties
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
impl Clone for SemanticsProperties
Source§fn clone(&self) -> SemanticsProperties
fn clone(&self) -> SemanticsProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more