pub trait AccessibilityIdExt {
// Required methods
fn is_focused(&self) -> bool;
fn request_focus(&self);
fn request_unfocus(&self);
fn new_unique() -> AccessibilityId;
}Expand description
Extension trait for AccessibilityId.
Pair an id with an element through .a11y_id(...), then call any of these
methods on the id to interact with focus.
fn focusable_box() -> impl IntoElement {
let a11y_id = use_a11y();
rect()
.a11y_id(a11y_id)
.a11y_focusable(true)
.on_mouse_down(move |_| a11y_id.request_focus())
.child(if a11y_id.is_focused() {
"Focused"
} else {
"Not focused"
})
}Required Methods§
Sourcefn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Whether the linked node is currently focused (via keyboard or pointer).
Sourcefn request_focus(&self)
fn request_focus(&self)
Request focus to be moved to the linked node.
Sourcefn request_unfocus(&self)
fn request_unfocus(&self)
Request focus to be cleared from the linked node.
Sourcefn new_unique() -> AccessibilityId
fn new_unique() -> AccessibilityId
Generate a unique AccessibilityId. Prefer use_a11y for component-scoped ids.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.