Expand description
Thread-local programmatic focus-request channel.
Widgets built in app code can’t reach the App’s
private focus path to focus themselves when they appear — e.g. a search
field that should grab the keyboard the instant its overlay opens. This
channel mirrors crate::animation::request_draw:
- The widget is built with a stable
FocusIdand returns it fromWidget::focus_id. - App logic calls
request_focuswith that id (typically from the same handler that makes the widget visible). - The
Appconsumes the pending request on its nextlayout, locates the focusable widget whosefocus_idmatches, and moves focus to it — dispatchingFocusGainedand (for text inputs) raising the on-screen keyboard.
Only one request is held at a time; a later request_focus before the
App services the previous one wins.
Functions§
- clear_
focus_ request - Discard any pending focus request without acting on it.
- request_
focus - Request that the widget whose
Widget::focus_idequalsidreceive focus on the next frame. Also wakes the host loop (viacrate::animation::request_draw) so the request is serviced promptly. - take_
focus_ request - Read-and-clear the pending focus request. Called by the
Apponce perlayout.
Type Aliases§
- FocusId
- Opaque, app-chosen identifier for a focusable widget. Values only need to be unique among the widgets that opt into focus-by-request.