pub struct FocusManager { /* private fields */ }Expand description
Tracks and moves keyboard focus within a WidgetTree.
Implementations§
Source§impl FocusManager
impl FocusManager
Sourcepub fn focusable_set(&self, tree: &WidgetTree) -> Vec<WidgetId>
pub fn focusable_set(&self, tree: &WidgetTree) -> Vec<WidgetId>
The ordered list of focusable nodes that focus may currently move between, honouring any active trap (only the trap’s focusable descendants — and the trap node itself if focusable — are included).
Sourcepub fn focus(&mut self, tree: &WidgetTree, id: WidgetId) -> bool
pub fn focus(&mut self, tree: &WidgetTree, id: WidgetId) -> bool
Focus id if it is currently focusable (and inside the trap, if any).
Returns true on success.
Sourcepub fn push_trap(
&mut self,
tree: &WidgetTree,
trap: WidgetId,
) -> Option<WidgetId>
pub fn push_trap( &mut self, tree: &WidgetTree, trap: WidgetId, ) -> Option<WidgetId>
Activate a focus trap rooted at trap. If the current focus falls
outside the trap, focus moves to the first focusable node within it.
Returns the node focused after activation, if any.
Sourcepub fn focus_next(&mut self, tree: &WidgetTree) -> Option<WidgetId>
pub fn focus_next(&mut self, tree: &WidgetTree) -> Option<WidgetId>
Move focus to the next focusable node in tab order (wraps around).
Returns the newly focused node, or None if nothing is focusable.
Sourcepub fn focus_prev(&mut self, tree: &WidgetTree) -> Option<WidgetId>
pub fn focus_prev(&mut self, tree: &WidgetTree) -> Option<WidgetId>
Move focus to the previous focusable node in tab order (wraps around).
Sourcepub fn autofocus(
&mut self,
tree: &WidgetTree,
is_autofocus: impl Fn(WidgetId) -> bool,
) -> Option<WidgetId>
pub fn autofocus( &mut self, tree: &WidgetTree, is_autofocus: impl Fn(WidgetId) -> bool, ) -> Option<WidgetId>
Focus the first node in tab order whose autofocus flag (as supplied by
is_autofocus) is true. Returns the focused node, if one matched.
The tree node has no dedicated autofocus field, so the predicate lets
callers decide (e.g. by inspecting a node’s label or an external map).
Sourcepub fn reconcile(&mut self, tree: &WidgetTree) -> bool
pub fn reconcile(&mut self, tree: &WidgetTree) -> bool
Drop focus if the focused node is no longer present or no longer
focusable (call after removing/reparenting nodes). Returns true if
focus was cleared as a result.
Trait Implementations§
Source§impl Clone for FocusManager
impl Clone for FocusManager
Source§fn clone(&self) -> FocusManager
fn clone(&self) -> FocusManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more