FocusRequester

@Stable
class FocusRequester

A hoistable handle that moves keyboard focus to the component it is bound to with focusRequester, so an application event - a validation failure, a toolbar action, a shortcut - can decide what the keyboard drives.

val search = rememberFocusRequester()
Button("Search", onClick = { search.requestFocus() })
TextField(query, onValueChange = { query = it }, modifier = SwingModifier.focusRequester(search))

A requester drives at most one component: binding it to a second one moves it there and leaves the first unbound.

Functions

Link copied to clipboard

Moves keyboard focus to the bound component, returning whether the request could be made. Returns false when no component is bound; otherwise delegates to the bound component's own requestFocusInWindow.