Skip to main content

FocusManager

Struct FocusManager 

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

Manages focus for the application.

Implementations§

Source§

impl FocusManager

Source

pub const TYPE: &'static TypeInfo = <FocusManager as crate::StaticType>::TYPE

The runtime type of this type.

Source§

impl FocusManager

Source

pub fn new() -> Rc<FocusManager>

Creates a focus manager.

Source

pub fn content_root(&self) -> Option<Ref<InputElement>>

The root of the content the focus manager navigates within.

Source

pub fn set_content_root(&self, value: Option<Ref<InputElement>>)

Sets the root of the content the focus manager navigates within.

Source

pub fn get_focused_element(&self) -> Option<Ref<InputElement>>

Gets the currently focused element.

Source

pub fn focus( &self, element: Option<&Ref<InputElement>>, method: NavigationMethod, key_modifiers: KeyModifiers, ) -> bool

Focuses a control.

element is the control to focus; None restores the focus of the current focus root or clears the focus. method is the method by which focus was changed and key_modifiers any key modifiers active at the time of focus. Returns true if the focus moved to a control.

Source

pub fn get_focused_element_in_scope( &self, scope: &StyledElement, ) -> Option<Ref<InputElement>>

Gets the element that is focused within a focus scope.

Source

pub fn set_focus_scope(&self, scope: &Ref<InputElement>)

Sets the currently focused scope: focus moves to the element that was last focused in the scope, or to the scope itself.

Source

pub fn remove_focus_root(&self, scope: &StyledElement)

Clears the focus if scope is the current focus root.

Source

pub fn get_is_focus_scope(e: &InputElement) -> bool

Whether an element is a focus scope.

Source

pub fn get_focus_manager(element: &InputElement) -> Option<Rc<FocusManager>>

The focus manager responsible for an element: the one of the input root the element is attached to, or the fallback instance.

Source

pub fn can_focus(e: &InputElement) -> bool

Whether an element can receive focus: it is focusable, effectively enabled and visible.

Source

pub fn try_move_focus( &self, direction: NavigationDirection, options: Option<&FindNextElementOptions>, ) -> bool

Attempts to change focus from the element with focus to the next focusable element in the specified direction.

Panics for directions other than next, previous, up, down, left and right.

Source

pub fn find_first_focusable_element(&self) -> Option<Ref<InputElement>>

Retrieves the first element that can receive focus within the content root.

Source

pub fn find_first_focusable_element_in( search_scope: &Ref<InputElement>, ) -> Option<Ref<InputElement>>

Retrieves the first element that can receive focus based on the specified scope.

Source

pub fn find_last_focusable_element(&self) -> Option<Ref<InputElement>>

Retrieves the last element that can receive focus within the content root.

Source

pub fn find_last_focusable_element_in( search_scope: &Ref<InputElement>, ) -> Option<Ref<InputElement>>

Retrieves the last element that can receive focus based on the specified scope.

Source

pub fn find_next_element( &self, direction: NavigationDirection, options: Option<&FindNextElementOptions>, ) -> Option<Ref<InputElement>>

Retrieves the element that should receive focus based on the specified navigation direction, without moving focus.

Panics for directions other than next, previous, up, down, left and right.

Trait Implementations§

Source§

impl IFocusManager for FocusManager

Source§

fn get_focused_element(&self) -> Option<Ref<InputElement>>

Gets the currently focused element.
Source§

fn focus( &self, element: Option<&Ref<InputElement>>, method: NavigationMethod, key_modifiers: KeyModifiers, ) -> bool

Focuses a control. Read more
Source§

fn try_move_focus( &self, direction: NavigationDirection, options: Option<&FindNextElementOptions>, ) -> bool

Attempts to change focus from the element with focus to the next focusable element in the specified direction. Read more
Source§

fn find_first_focusable_element(&self) -> Option<Ref<InputElement>>

Retrieves the first element that can receive focus.
Source§

fn find_last_focusable_element(&self) -> Option<Ref<InputElement>>

Retrieves the last element that can receive focus.
Source§

fn find_next_element( &self, direction: NavigationDirection, options: Option<&FindNextElementOptions>, ) -> Option<Ref<InputElement>>

Retrieves the element that should receive focus based on the specified navigation direction. Read more
Source§

fn as_any(&self) -> &dyn Any

The focus manager as Any, for downcasting to the concrete type.
Source§

impl StaticType for FocusManager

Source§

const TYPE: &'static TypeInfo

The runtime type.

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.