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 moreSource§impl Debug for FocusManager
impl Debug for FocusManager
Source§impl Default for FocusManager
impl Default for FocusManager
Source§fn default() -> FocusManager
fn default() -> FocusManager
Auto Trait Implementations§
impl Freeze for FocusManager
impl RefUnwindSafe for FocusManager
impl Send for FocusManager
impl Sync for FocusManager
impl Unpin for FocusManager
impl UnsafeUnpin for FocusManager
impl UnwindSafe for FocusManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more