# FocusManager

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/input/struct-focusmanager/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct FocusManager
```

Manages focus for the application.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L17)

## Members

- [`TYPE`](#assoc_const-type)
- [`new`](#function-new)
- [`content_root`](#function-content_root)
- [`set_content_root`](#function-set_content_root)
- [`get_focused_element`](#function-get_focused_element)
- [`focus`](#function-focus)
- [`get_focused_element_in_scope`](#function-get_focused_element_in_scope)
- [`set_focus_scope`](#function-set_focus_scope)
- [`remove_focus_root`](#function-remove_focus_root)
- [`get_is_focus_scope`](#function-get_is_focus_scope)
- [`get_focus_manager`](#function-get_focus_manager)
- [`can_focus`](#function-can_focus)
- [`try_move_focus`](#function-try_move_focus)
- [`find_first_focusable_element`](#function-find_first_focusable_element)
- [`find_first_focusable_element_in`](#function-find_first_focusable_element_in)
- [`find_last_focusable_element`](#function-find_last_focusable_element)
- [`find_last_focusable_element_in`](#function-find_last_focusable_element_in)
- [`find_next_element`](#function-find_next_element)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L25)

<a id="function-new"></a>

### new

```rust
fn new() -> Rc<FocusManager>
```

Creates a focus manager.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L64)

<a id="function-content_root"></a>

### content_root

```rust
fn content_root(self: &Self) -> Option<Ref<InputElement>>
```

The root of the content the focus manager navigates within.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L85)

<a id="function-set_content_root"></a>

### set_content_root

```rust
fn set_content_root(self: &Self, value: Option<Ref<InputElement>>)
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L90)

<a id="function-get_focused_element"></a>

### get_focused_element

```rust
fn get_focused_element(self: &Self) -> Option<Ref<InputElement>>
```

Gets the currently focused element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L109)

<a id="function-focus"></a>

### focus

```rust
fn focus(self: &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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L119)

<a id="function-get_focused_element_in_scope"></a>

### get_focused_element_in_scope

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

Gets the element that is focused within a focus scope.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L207)

<a id="function-set_focus_scope"></a>

### set_focus_scope

```rust
fn set_focus_scope(self: &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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L213)

<a id="function-remove_focus_root"></a>

### remove_focus_root

```rust
fn remove_focus_root(self: &Self, scope: &StyledElement)
```

Clears the focus if `scope` is the current focus root.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L233)

<a id="function-get_is_focus_scope"></a>

### get_is_focus_scope

```rust
fn get_is_focus_scope(e: &InputElement) -> bool
```

Whether an element is a focus scope.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L240)

<a id="function-get_focus_manager"></a>

### get_focus_manager

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L246)

<a id="function-can_focus"></a>

### can_focus

```rust
fn can_focus(e: &InputElement) -> bool
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L252)

<a id="function-try_move_focus"></a>

### try_move_focus

```rust
fn try_move_focus(self: &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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L357)

<a id="function-find_first_focusable_element"></a>

### find_first_focusable_element

```rust
fn find_first_focusable_element(self: &Self) -> Option<crate::Ref<super::InputElement>>
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L374)

<a id="function-find_first_focusable_element_in"></a>

### find_first_focusable_element_in

```rust
fn find_first_focusable_element_in(search_scope: &crate::Ref<super::InputElement>) -> Option<crate::Ref<super::InputElement>>
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L384)

<a id="function-find_last_focusable_element"></a>

### find_last_focusable_element

```rust
fn find_last_focusable_element(self: &Self) -> Option<crate::Ref<super::InputElement>>
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L390)

<a id="function-find_last_focusable_element_in"></a>

### find_last_focusable_element_in

```rust
fn find_last_focusable_element_in(search_scope: &crate::Ref<super::InputElement>) -> Option<crate::Ref<super::InputElement>>
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L400)

<a id="function-find_next_element"></a>

### find_next_element

```rust
fn find_next_element(self: &Self, direction: NavigationDirection, options: Option<&FindNextElementOptions>) -> Option<crate::Ref<super::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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/focus_manager.rs#L409)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`IFocusManager`](/docs/0.5.0/api/ferroui-base/input/trait-ifocusmanager/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
