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 maybe_toggled(self, on: Option<bool>) -> Self
pub fn maybe_toggled(self, on: Option<bool>) -> Self
Marks it on, off, or partly on — None being the third answer, not a
missing one.
Sourcepub fn range(self, min: f32, value: f32, max: f32) -> Self
pub fn range(self, min: f32, value: f32, max: f32) -> Self
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: &Self) -> Self
pub fn over(self, under: &Self) -> Self
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.