public class FocusRequester @RememberInComposition public constructor()
The FocusRequester is used in conjunction with Modifier.focusRequester to send requests to change focus.
Functions
requestFocus
@Deprecated(
message = "use the version the has a FocusDirection",
replaceWith = ReplaceWith("this.requestFocus()"),
level = DeprecationLevel.HIDDEN,
)
public fun requestFocus()
Use this function to request focus. 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.
requestFocus
public 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.
Parameters
| focusDirection | The direction passed to the FocusTargetModifierNode to indicate the direction that the focus request comes from. |
Return
true if the focus was successfully requested or false if the focus request was canceled.
captureFocus
public fun captureFocus(): Boolean
Deny requests to clear focus.
Use this function to send a request to capture focus. If a component captures focus, it will send a FocusState object to its associated onFocusChanged modifiers where [FocusState.isCaptured]() == true.
When a component is in a 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
public 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.
When a component is in a Captured state, all focus requests from other components are declined. .
Return
true if the captured focus was successfully released. i.e. At the end of this operation, one of the components associated with this focusRequester freed focus.
saveFocusedChild
public 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.
Return
true if the focus target associated with this FocusRequester has a focused child and we successfully saved a reference to it.
restoreFocusedChild
public 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.
Return
true if we successfully restored focus to one of the children of the focusTarget associated with this FocusRequester
Members
Companion
public companion object
Properties
Default
public val Default: FocusRequester = FocusRequester()
Default focusRequester, which when used in Modifier.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
public val Cancel: FocusRequester = FocusRequester()
Cancelled focusRequester, which when used in Modifier.focusProperties implies that we want to block focus search from proceeding in the specified direction.
Functions
createRefs
public fun createRefs(): FocusRequesterFactory
Convenient way to create multiple FocusRequesters, which can to be used to request focus, or to specify a focus traversal order.
Members
FocusRequesterFactory
public object FocusRequesterFactory
Convenient way to create multiple FocusRequester instances.
Functions
component1
public operator fun component1(): FocusRequester
component2
public operator fun component2(): FocusRequester
component3
public operator fun component3(): FocusRequester
component4
public operator fun component4(): FocusRequester
component5
public operator fun component5(): FocusRequester
component6
public operator fun component6(): FocusRequester
component7
public operator fun component7(): FocusRequester
component8
public operator fun component8(): FocusRequester
component9
public operator fun component9(): FocusRequester
component10
public operator fun component10(): FocusRequester
component11
public operator fun component11(): FocusRequester
component12
public operator fun component12(): FocusRequester
component13
public operator fun component13(): FocusRequester
component14
public operator fun component14(): FocusRequester
component15
public operator fun component15(): FocusRequester
component16
public operator fun component16(): FocusRequester