pub struct FocusRequester {
pub target: Rc<RefCell<Option<u64>>>,
}Expand description
A handle that can programmatically request focus for a widget.
Similar to Compose’s FocusRequester. Create one via remember(FocusRequester::new),
attach it via .focus_requester(...) on a modifier, and call request_focus() to
move keyboard focus to the associated widget on the next frame.
Fields§
§target: Rc<RefCell<Option<u64>>>Target view ID, set during layout/paint by the modifier system.
Implementations§
Source§impl FocusRequester
impl FocusRequester
pub fn new() -> Self
Sourcepub fn request_focus(&self)
pub fn request_focus(&self)
Request focus for the associated widget on the next frame. Queued; unlike the old single-slot behavior, multiple requests in one frame are all honored in order. If the target is not laid out yet the request is dropped (target assigned during layout/paint).
Sourcepub fn try_request_focus(&self) -> bool
pub fn try_request_focus(&self) -> bool
Enqueue a focus request, reporting whether it was accepted.
Returns false when the target is not laid out yet (request dropped)
or when another target holds the capture lock.
Sourcepub fn request_focus_directed(&self, _direction: FocusDirection) -> bool
pub fn request_focus_directed(&self, _direction: FocusDirection) -> bool
Request focus for the associated widget from a traversal direction.
Directional enter delegation is not implemented (focus targets are
flat, not containers), so this behaves like try_request_focus
and reports acceptance the same way.
Sourcepub fn free_focus(&self)
pub fn free_focus(&self)
Free/clear focus from the associated widget on the next frame.
If the associated widget currently has focus, focus is cleared entirely.
Corresponds to Compose’s freeFocus(). Releases this target’s capture
lock when held.
Sourcepub fn capture_focus(&self) -> bool
pub fn capture_focus(&self) -> bool
Capture focus for the associated widget: focus moves to the target and
stays pinned there until free_focus. Other
targets’ requests are denied while the lock is held.
Returns false when the target is not laid out yet.