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) -> Self
pub fn new(role: Role) -> Self
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>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Sets the accessible name, replacing the name from content.
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Sets a description, read after the name.
Sourcepub fn value(self, value: impl Into<String>) -> Self
pub fn value(self, value: impl Into<String>) -> Self
Sets a text value (text fields, combo boxes).
Sourcepub fn numeric(self, value: f64, min: f64, max: f64, step: Option<f64>) -> Self
pub fn numeric(self, value: f64, min: f64, max: f64, step: Option<f64>) -> Self
Sets a numeric value and its range.
Sourcepub fn read_only(self, read_only: bool) -> Self
pub fn read_only(self, read_only: bool) -> Self
Marks the control’s value as readable but not changeable.