pub struct Semantics { /* private fields */ }Expand description
How a node appears to screen readers: its Role, name and state.
Built-in components set this themselves. Custom components call
BuildCx::semantics on the node they return:
use ravenrs_core::Role;
use ravenrs_widgets::Semantics;
let s = Semantics::new(Role::Switch).name("Wi-Fi").toggled(true);
assert_eq!(s.role(), Role::Switch);Without semantics, a focusable node is announced as a button named by the text inside it, text is announced as a label, and other boxes are transparent: their children belong to the nearest described ancestor.
Implementations§
Source§impl Semantics
impl Semantics
Sourcepub fn new(role: Role) -> Semantics
pub fn new(role: Role) -> Semantics
A node with this role, named by its content when the role allows it.
Hides the node and everything inside it from assistive technology (decorations, duplicated content).
Sourcepub fn name(self, name: impl Into<String>) -> Semantics
pub fn name(self, name: impl Into<String>) -> Semantics
Sets the accessible name, replacing the name from content.
Sourcepub fn description(self, description: impl Into<String>) -> Semantics
pub fn description(self, description: impl Into<String>) -> Semantics
Sets a description, read after the name.
Sourcepub fn value(self, value: impl Into<String>) -> Semantics
pub fn value(self, value: impl Into<String>) -> Semantics
Sets a text value (text fields, combo boxes).
Sourcepub fn numeric(
self,
value: f64,
min: f64,
max: f64,
step: Option<f64>,
) -> Semantics
pub fn numeric( self, value: f64, min: f64, max: f64, step: Option<f64>, ) -> Semantics
Sets a numeric value and its range.
Sourcepub fn disabled(self, disabled: bool) -> Semantics
pub fn disabled(self, disabled: bool) -> Semantics
Marks the control as not responding to input.
Sourcepub fn read_only(self, read_only: bool) -> Semantics
pub fn read_only(self, read_only: bool) -> Semantics
Marks the control’s value as readable but not changeable.