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
Nested classes | |
---|---|
Convenient way to create multiple FocusRequester instances. |
Public constructors | |
---|---|
<init>() 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. |
Companion functions | |
---|---|
FocusRequester.FocusRequesterFactory |
Convenient way to create multiple FocusRequesters, which can to be used to request focus, or to specify a focus traversal order. |
Companion properties | |
---|---|
FocusRequester |
Default focusRequester, which when used in Modifier.focusOrder implies that we want to use the default system focus order, that is based on the location on items on the screen. |
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.
Companion functions
createRefs
fun createRefs(): FocusRequester.FocusRequesterFactory
Convenient way to create multiple FocusRequesters, which can to be used to request focus, or to specify a focus traversal order.
Companion properties
Default
val Default: FocusRequester
Default focusRequester, which when used in Modifier.focusOrder implies that we want to use the default system focus order, that is based on the location on items on the screen.