pub struct FocusScopeState { /* private fields */ }Expand description
Shared retained focus history for a FocusScope.
Presentation policies call Self::request_restore when a previously
hidden pane or route becomes visible. The associated scope performs the
focus change on its next runtime wake without rebuilding its child subtree,
unless focus is by then on a widget outside the scope.
Implementations§
Source§impl FocusScopeState
impl FocusScopeState
pub fn new() -> Self
Sourcepub fn last_focused(&self) -> Option<WidgetId>
pub fn last_focused(&self) -> Option<WidgetId>
The widget in the scope that had focus last, which may since have moved elsewhere. Commands for “the editor you were using”, such as a toolbar’s, go to it.
Sourcepub fn last_focused_observable(
&self,
) -> impl Observable<Option<WidgetId>> + Clone + Send + Sync + 'static
pub fn last_focused_observable( &self, ) -> impl Observable<Option<WidgetId>> + Clone + Send + Sync + 'static
Self::last_focused as a value to observe, so a widget showing it
follows focus into the scope.
pub fn request_restore(&self) -> bool
Sourcepub fn request_focus(&self) -> bool
pub fn request_focus(&self) -> bool
Move focus into the scope at its next frame: to the descendant chosen
by the scope’s restore policy, even when focus is currently outside
the scope. Use this for application-driven focus, such as focusing a
search field; Self::request_restore leaves focus the person moved
elsewhere alone.