🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

FocusRequester

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

Source set: Common
public class FocusRequester @RememberInComposition public constructor()

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

Functions

requestFocus

Source set: Common
@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

Source set: Common
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

Source set: Common
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

Source set: Common
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

Source set: Common
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

Source set: Common
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

Source set: Common
public companion object

Properties

Default

Source set: Common
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

Source set: Common
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

Source set: Common
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

Source set: Common
public object FocusRequesterFactory

Convenient way to create multiple FocusRequester instances.

Functions

component1

Source set: Common
public operator fun component1(): FocusRequester

component2

Source set: Common
public operator fun component2(): FocusRequester

component3

Source set: Common
public operator fun component3(): FocusRequester

component4

Source set: Common
public operator fun component4(): FocusRequester

component5

Source set: Common
public operator fun component5(): FocusRequester

component6

Source set: Common
public operator fun component6(): FocusRequester

component7

Source set: Common
public operator fun component7(): FocusRequester

component8

Source set: Common
public operator fun component8(): FocusRequester

component9

Source set: Common
public operator fun component9(): FocusRequester

component10

Source set: Common
public operator fun component10(): FocusRequester

component11

Source set: Common
public operator fun component11(): FocusRequester

component12

Source set: Common
public operator fun component12(): FocusRequester

component13

Source set: Common
public operator fun component13(): FocusRequester

component14

Source set: Common
public operator fun component14(): FocusRequester

component15

Source set: Common
public operator fun component15(): FocusRequester

component16

Source set: Common
public operator fun component16(): FocusRequester