pub struct FocusScope { /* private fields */ }Expand description
A FocusScope is similar to a Focus, but also serves as a scope for its descendants,
restricting focus traversal to the scoped controls.
For example a new FocusScope is created automatically when a route is pushed, keeping
the focus traversal from moving to a control in a previous route.
Like Focus, FocusScope provides an on_focus_change as a way to be notified when
the focus is given to or removed from this widget.
Managing a FocusScopeNode means managing its lifecycle, listening for changes in focus,
and re-parenting it when needed to keep the focus hierarchy in sync with the widget
hierarchy. This widget does all of those things for you.
FocusScopeNodes remember the last FocusNode that was focused within their
descendants.
Implementations§
Source§impl FocusScope
impl FocusScope
Sourcepub fn new<K>(child: impl IntoWidget<K>) -> FocusScope
pub fn new<K>(child: impl IntoWidget<K>) -> FocusScope
Creates a widget that manages a FocusScopeNode.
Sourcepub fn with_external_focus_node<K>(
child: impl IntoWidget<K>,
focus_scope_node: Ref<FocusScopeNode>,
) -> FocusScope
pub fn with_external_focus_node<K>( child: impl IntoWidget<K>, focus_scope_node: Ref<FocusScopeNode>, ) -> FocusScope
Creates a FocusScope widget that uses the given focus_scope_node as the source of
truth for attributes on the node, rather than the attributes of this widget.
Sourcepub fn node(self, node: Ref<FocusScopeNode>) -> FocusScope
pub fn node(self, node: Ref<FocusScopeNode>) -> FocusScope
Dart FocusScope(node:).
Sourcepub fn key(self, key: KeyRef) -> FocusScope
pub fn key(self, key: KeyRef) -> FocusScope
Dart FocusScope(key:).
Sourcepub fn parent_node(self, parent_node: FocusNodeRef) -> FocusScope
pub fn parent_node(self, parent_node: FocusNodeRef) -> FocusScope
Dart FocusScope(parentNode:).
Sourcepub fn autofocus(self, autofocus: bool) -> FocusScope
pub fn autofocus(self, autofocus: bool) -> FocusScope
Dart FocusScope(autofocus:).
Sourcepub fn on_focus_change(
self,
on_focus_change: impl Fn(&mut App, bool) + 'static,
) -> FocusScope
pub fn on_focus_change( self, on_focus_change: impl Fn(&mut App, bool) + 'static, ) -> FocusScope
Dart FocusScope(onFocusChange:).
Sourcepub fn on_key_event(self, on_key_event: FocusOnKeyEventCallback) -> FocusScope
pub fn on_key_event(self, on_key_event: FocusOnKeyEventCallback) -> FocusScope
Dart FocusScope(onKeyEvent:).
Sourcepub fn can_request_focus(self, can_request_focus: bool) -> FocusScope
pub fn can_request_focus(self, can_request_focus: bool) -> FocusScope
Dart FocusScope(canRequestFocus:).
Sourcepub fn skip_traversal(self, skip_traversal: bool) -> FocusScope
pub fn skip_traversal(self, skip_traversal: bool) -> FocusScope
Dart FocusScope(skipTraversal:).
Sourcepub fn descendants_are_focusable(
self,
descendants_are_focusable: bool,
) -> FocusScope
pub fn descendants_are_focusable( self, descendants_are_focusable: bool, ) -> FocusScope
Dart FocusScope(descendantsAreFocusable:).
Sourcepub fn descendants_are_traversable(
self,
descendants_are_traversable: bool,
) -> FocusScope
pub fn descendants_are_traversable( self, descendants_are_traversable: bool, ) -> FocusScope
Dart FocusScope(descendantsAreTraversable:).
Sourcepub fn include_semantics(self, include_semantics: bool) -> FocusScope
pub fn include_semantics(self, include_semantics: bool) -> FocusScope
Dart FocusScope(includeSemantics:).
Sourcepub fn debug_label(self, debug_label: impl Into<String>) -> FocusScope
pub fn debug_label(self, debug_label: impl Into<String>) -> FocusScope
Dart FocusScope(debugLabel:).
Sourcepub fn of(
app: &mut App,
context: BuildContext,
create_dependency: bool,
) -> Handle<FocusScopeNode>
pub fn of( app: &mut App, context: BuildContext, create_dependency: bool, ) -> Handle<FocusScopeNode>
Returns the AnyFocusNode::nearest_scope of the Focus or FocusScope that most
tightly encloses the given context.
If this node doesn’t have a Focus or FocusScope widget ancestor, then the
FocusManager’s root scope is returned.
Trait Implementations§
Source§impl Debug for FocusScope
impl Debug for FocusScope
Source§impl StatefulWidget for FocusScope
impl StatefulWidget for FocusScope
Source§type State = FocusScopeState
type State = FocusScopeState
Source§fn create_state(&self) -> FocusScopeState
fn create_state(&self) -> FocusScopeState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for FocusScope
impl !Send for FocusScope
impl !Sync for FocusScope
impl !UnwindSafe for FocusScope
impl Forget for FocusScope
impl Freeze for FocusScopewhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
NonZero<u32>: Freeze,
&'static FocusNodeVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl Move for FocusScope
impl Unpin for FocusScope
impl UnsafeUnpin for FocusScopewhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static FocusNodeVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.