Skip to main content

FocusScope

Struct FocusScope 

Source
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

Source

pub fn new<K>(child: impl IntoWidget<K>) -> FocusScope

Creates a widget that manages a FocusScopeNode.

Source

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.

Source

pub fn node(self, node: Ref<FocusScopeNode>) -> FocusScope

Dart FocusScope(node:).

Source

pub fn key(self, key: KeyRef) -> FocusScope

Dart FocusScope(key:).

Source

pub fn parent_node(self, parent_node: FocusNodeRef) -> FocusScope

Dart FocusScope(parentNode:).

Source

pub fn autofocus(self, autofocus: bool) -> FocusScope

Dart FocusScope(autofocus:).

Source

pub fn on_focus_change( self, on_focus_change: impl Fn(&mut App, bool) + 'static, ) -> FocusScope

Dart FocusScope(onFocusChange:).

Source

pub fn on_key_event(self, on_key_event: FocusOnKeyEventCallback) -> FocusScope

Dart FocusScope(onKeyEvent:).

Source

pub fn can_request_focus(self, can_request_focus: bool) -> FocusScope

Dart FocusScope(canRequestFocus:).

Source

pub fn skip_traversal(self, skip_traversal: bool) -> FocusScope

Dart FocusScope(skipTraversal:).

Source

pub fn descendants_are_focusable( self, descendants_are_focusable: bool, ) -> FocusScope

Dart FocusScope(descendantsAreFocusable:).

Source

pub fn descendants_are_traversable( self, descendants_are_traversable: bool, ) -> FocusScope

Dart FocusScope(descendantsAreTraversable:).

Source

pub fn include_semantics(self, include_semantics: bool) -> FocusScope

Dart FocusScope(includeSemantics:).

Source

pub fn debug_label(self, debug_label: impl Into<String>) -> FocusScope

Dart FocusScope(debugLabel:).

Source

pub fn focus(&self) -> &Focus

The Focus fields this widget inherits.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for FocusScope

Source§

type State = FocusScopeState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> FocusScopeState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 debug_check_constructor(&self)

Source§

fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>

Source§

fn type_name(&self) -> &'static str

See 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 FocusScope
where *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
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn Fn(&mut App, bool)>: Unpin, Rc<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for FocusScope
where *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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>