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

FocusRequester

class FocusRequester
kotlin.Any
   ↳ androidx.compose.ui.focus.FocusRequester

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

Summary

Public constructors

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

Public methods
Boolean

Deny requests to clear focus.

Boolean

Use this function to send a request to release focus when one of the components associated with this FocusRequester is in a Captured state.

Unit

Use this function to request focus.

Public constructors

<init>

FocusRequester()

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

Public methods

captureFocus

fun captureFocus(): Boolean

Deny requests to clear focus.

Use this function to send a request to capture the focus. If a component is captured, its state will be set to Captured. When a component is in this state, it holds onto focus until freeFocus is called. When a component is in the Captured state, all focus requests from other components are declined.

Return
true if the focus was successfully captured by one of the focus modifiers associated with this FocusRequester. false otherwise.

freeFocus

fun freeFocus(): Boolean

Use this function to send a request to release focus when one of the components associated with this FocusRequester is in a Captured state.

When the node is in the Captured state, it rejects all requests to clear focus. Calling freeFocus puts the node in the Active state, where it is no longer preventing other nodes from requesting focus.

Return
true if the focus was successfully released. i.e. At the end of this operation, one of the components associated with this focusRequester is in the Active state. false otherwise.

requestFocus

fun requestFocus(): Unit

Use this function to request focus. If the system grants focus to a component associated with this FocusRequester, its state will be set to Active.