Focus Requester
Holds a stable focus handle independently of any platform View instance.
One requester may attach to multiple targets. Requests are offered in attachment order until a target accepts. Connector membership and restoration state are synchronized; connector callbacks run synchronously on the caller's thread without holding the membership lock, except for focus-state inspection during saveFocusedChild.
Samples
val requester = FocusRequester()
val target = RecordingFocusConnector(restorationKey = "search-field")
requester.attach(target)
check(requester.requestFocus())
check(target.lastDirection == FocusDirection.Enter)
target.state = FocusState(isFocused = true, hasFocus = true)
check(requester.saveFocusedChild())
requester.detach(target)
val remounted = RecordingFocusConnector(restorationKey = "search-field")
requester.attach(remounted)
check(remounted.lastDirection == FocusDirection.Enter)Content copied to clipboard
Functions
Link copied to clipboard
Attaches one platform focus target.
Link copied to clipboard
Detaches connector from future requests.
Link copied to clipboard
Requests focus from attached targets in attachment order.
Link copied to clipboard
Restores the target previously captured by saveFocusedChild.
Link copied to clipboard
Saves the restoration key of the first attached target whose subtree owns focus.