Skip to main content

FocusManager

Struct FocusManager 

Source
pub struct FocusManager { /* private fields */ }
Expand description

Central focus coordinator.

Tracks focus state, navigation history, focus traps (for modals), and focus indicator styling. Emits FocusEvents on focus changes.

Implementations§

Source§

impl FocusManager

Source

pub fn new() -> Self

Create a new focus manager.

Source

pub fn graph(&self) -> &FocusGraph

Access the underlying focus graph.

Source

pub fn graph_mut(&mut self) -> &mut FocusGraph

Mutably access the underlying focus graph.

Source

pub fn current(&self) -> Option<FocusId>

Get currently focused widget.

Source

pub fn is_focused(&self, id: FocusId) -> bool

Check if a widget is focused.

Source

pub fn focus(&mut self, id: FocusId) -> Option<FocusId>

Set focus to widget, returns previous focus.

Source

pub fn blur(&mut self) -> Option<FocusId>

Remove focus from current widget.

Source

pub fn navigate(&mut self, dir: NavDirection) -> bool

Move focus in direction.

Source

pub fn focus_next(&mut self) -> bool

Move to next in tab order.

Source

pub fn focus_prev(&mut self) -> bool

Move to previous in tab order.

Source

pub fn focus_first(&mut self) -> bool

Focus first focusable widget.

Source

pub fn focus_last(&mut self) -> bool

Focus last focusable widget.

Source

pub fn focus_back(&mut self) -> bool

Go back to previous focus.

Source

pub fn clear_history(&mut self)

Clear focus history.

Source

pub fn push_trap(&mut self, group_id: u32)

Push focus trap (for modals).

Source

pub fn pop_trap(&mut self) -> bool

Pop focus trap, restore previous focus.

Source

pub fn is_trapped(&self) -> bool

Check if focus is currently trapped.

Source

pub fn create_group(&mut self, id: u32, members: Vec<FocusId>)

Create focus group.

Source

pub fn add_to_group(&mut self, group_id: u32, widget_id: FocusId)

Add widget to group.

Source

pub fn remove_from_group(&mut self, group_id: u32, widget_id: FocusId)

Remove widget from group.

Source

pub fn focus_event(&self) -> Option<&FocusEvent>

Get the last focus event.

Source

pub fn take_focus_event(&mut self) -> Option<FocusEvent>

Take and clear the last focus event.

Source

pub fn indicator(&self) -> &FocusIndicator

Get the focus indicator configuration.

Source

pub fn set_indicator(&mut self, indicator: FocusIndicator)

Set the focus indicator configuration.

Source

pub fn focus_change_count(&self) -> u64

Total number of focus changes since creation (for metrics).

Trait Implementations§

Source§

impl Debug for FocusManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FocusManager

Source§

fn default() -> FocusManager

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more