androidx.compose.ui.focus
FocusRequester
Class · from org.jetbrains.compose.ui:ui:1.12.2
No hand-written docs yet.
The FocusRequester is used in conjunction with Modifier.focusRequester``androidx.compose.ui.focus.focusRequester to send requests to change focus.
class FocusRequester
How to get one
Ready-made values and functions that return it
Used by
Parameters that take a FocusRequester.
DatePicker(focusRequester)DateRangePicker(focusRequester)focusRequester(focusRequester)focusRestorer(fallback)
Properties
Default
val Default: FocusRequester
Default focusRequester, which when used in Modifier.focusProperties``focusProperties implies that we want to use the default system focus order, that is based on the position of the items on the screen.
Cancel
val Cancel: FocusRequester
Cancelled focusRequester, which when used in Modifier.focusProperties``focusProperties implies that we want to block focus search from proceeding in the specified direction``FocusDirection.
Functions
requestFocus
fun requestFocus(
focusDirection: FocusDirection = Enter,
): Boolean
Use this function to request focus with a specific direction. If the system grants focus to a component associated with this FocusRequester, its onFocusChanged modifiers will receive a FocusState object where FocusState.isFocused is true.
captureFocus
fun captureFocus(): Boolean
Deny requests to clear focus.
freeFocus
fun freeFocus(): Boolean
Use this function to send a request to free focus when one of the components associated with this FocusRequester is in a Captured state. If a component frees focus, it will send a FocusState object to its associated onFocusChanged modifiers where FocusState.isCaptured == false.
saveFocusedChild
fun saveFocusedChild(): Boolean
Use this function to request the focus target to save a reference to the currently focused child in its saved instance state. After calling this, focus can be restored to the saved child by making a call to restoreFocusedChild.
restoreFocusedChild
fun restoreFocusedChild(): Boolean
Use this function to restore focus to one of the children of the node pointed to by this FocusRequester. This restores focus to a previously focused child that was saved by using saveFocusedChild.
createRefs
fun createRefs(): FocusRequesterFactory
Convenient way to create multiple FocusRequesters, which can to be used to request focus, or to specify a focus traversal order.
Nested types
FocusRequesterFactory
Library docs
The FocusRequester is used in conjunction with
Modifier.focusRequester``androidx.compose.ui.focus.focusRequester to send requests to change
focus.