# IFocusManager

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/input/trait-ifocusmanager/

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

```rust
trait IFocusManager
```

Manages focus for the application.

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

## Members

- [`get_focused_element`](#function-get_focused_element)
- [`focus`](#function-focus)
- [`try_move_focus`](#function-try_move_focus)
- [`find_first_focusable_element`](#function-find_first_focusable_element)
- [`find_last_focusable_element`](#function-find_last_focusable_element)
- [`find_next_element`](#function-find_next_element)
- [`as_any`](#function-as_any)

<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/i_focus_manager.rs#L8)

<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` 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/i_focus_manager.rs#L16)

<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.

`direction` must be one of next, previous, left, right, up and down.
`options` help identify the next element to receive focus. Returns
true if focus moved.

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

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

### find_first_focusable_element

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

Retrieves the first element that can receive focus.

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

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

### find_last_focusable_element

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

Retrieves the last element that can receive focus.

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

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

### find_next_element

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

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

`direction` must be one of next, previous, left, right, up and down.
`options` help identify the next element to receive focus.

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

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

### as_any

```rust
fn as_any(self: &Self) -> &dyn Any
```

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

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

## Trait implementations

- [`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/).
