pub struct FocusRequester { /* private fields */ }Expand description
A handle an app holds to move focus onto a node imperatively.
remember one, hang it on a node with
Modifier::focus_requester next to a
Modifier::focus_target (or
Modifier::on_focus_changed), and
call request_focus — from a click handler, an
effect that runs once a screen appears, wherever the app decides focus
should move.
ⓘ
let requester = remember(FocusRequester::new).with(Clone::clone);
// ... in the composition:
Modifier::empty().focus_requester(&requester).focus_target()
// ... later, imperatively:
requester.request_focus().ok();Implementations§
Source§impl FocusRequester
impl FocusRequester
pub fn new() -> Self
Sourcepub fn request_focus(&self) -> Result<(), FocusRequestError>
pub fn request_focus(&self) -> Result<(), FocusRequestError>
Moves focus onto the node this requester is attached to.
See FocusRequestError for the two predictable ways this can fail
instead of moving focus.
Trait Implementations§
Source§impl Clone for FocusRequester
impl Clone for FocusRequester
Source§fn clone(&self) -> FocusRequester
fn clone(&self) -> FocusRequester
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FocusRequester
impl Debug for FocusRequester
Source§impl Default for FocusRequester
impl Default for FocusRequester
Source§fn default() -> FocusRequester
fn default() -> FocusRequester
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for FocusRequester
impl !Send for FocusRequester
impl !Sync for FocusRequester
impl !UnwindSafe for FocusRequester
impl Freeze for FocusRequester
impl Unpin for FocusRequester
impl UnsafeUnpin for FocusRequester
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more