Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.ui.focus

Interfaces

FocusEventModifier

A modifier that can be used to observe focus state events.

FocusManager

FocusOrderModifier

A modifier that can be used to set a custom focus traversal order.

FocusRequesterModifier

A modifier that can be used to pass in a FocusRequester that can be used to request focus state changes.

Classes

FocusOrder

Specifies custom focus destinations that are used instead of the default focus traversal order.

FocusRequester

The FocusRequester is used in conjunction with Modifier.focusRequester to send requests for focus state change.

Enums

FocusState

Different states of the focus system.

Extension functions summary

For Modifier
Modifier

Add this modifier to a component to make it focusable.

Modifier
Modifier.focusOrder(focusOrderReceiver: FocusOrder.() -> Unit)

Use this modifier to specify a custom focus traversal order.

Modifier
Modifier.focusOrder(focusRequester: FocusRequester, focusOrderReceiver: FocusOrder.() -> Unit)

A modifier that lets you specify a FocusRequester for the current composable along with focusOrder.

Modifier

Add this modifier to a component to observe changes to focus state.

Modifier
Modifier.onFocusChanged(onFocusChanged: (FocusState) -> Unit)

Add this modifier to a component to observe focus state events.

Modifier
Modifier.onFocusEvent(onFocusEvent: (FocusState) -> Unit)

Add this modifier to a component to observe focus state events.

Extension properties summary

For FocusState
Boolean

Converts a focus state into a boolean value indicating if the component is focused or not.

Extension functions

focusModifier

fun Modifier.focusModifier(): Modifier

Add this modifier to a component to make it focusable.

focusOrder

fun Modifier.focusOrder(focusOrderReceiver: FocusOrder.() -> Unit): Modifier

Use this modifier to specify a custom focus traversal order.

Parameters
focusOrderReceiver: FocusOrder.() -> Unit Specifies FocusRequesters that are used when the user wants to move the current focus to the next item, or wants to move focus left, right, up or down.

focusOrder

fun Modifier.focusOrder(
    focusRequester: FocusRequester,
    focusOrderReceiver: FocusOrder.() -> Unit
): Modifier

A modifier that lets you specify a FocusRequester for the current composable along with focusOrder.

focusRequester

fun Modifier.focusRequester(focusRequester: FocusRequester): Modifier

Add this modifier to a component to observe changes to focus state.

onFocusChanged

fun Modifier.onFocusChanged(onFocusChanged: (FocusState) -> Unit): Modifier

Add this modifier to a component to observe focus state events. onFocusChanged is invoked only when the focus state changes.

If you want to be notified every time the internal focus state is written to (even if it hasn't changed), use onFocusEvent instead.

onFocusEvent

fun Modifier.onFocusEvent(onFocusEvent: (FocusState) -> Unit): Modifier

Add this modifier to a component to observe focus state events.

Extension properties

isFocused

val FocusState.isFocused: Boolean

Converts a focus state into a boolean value indicating if the component is focused or not.

Return
true if the component is focused, false otherwise.