Skip to main content

FocusScopeNode

Struct FocusScopeNode 

Source
pub struct FocusScopeNode { /* private fields */ }
Expand description

A subclass of FocusNode that acts as a scope for its descendants, maintaining information about which descendant is currently or was last focused.

Please see the FocusScope and Focus widgets, which are utility widgets that manage their own FocusScopeNodes and FocusNodes, respectively. If they aren’t appropriate, FocusScopeNodes can be managed directly.

FocusScopeNode organizes FocusNodes into scopes. Scopes form sub-trees of nodes that can be traversed as a group. Within a scope, the most recent nodes to have focus are remembered, and if a node is focused and then removed, the original node receives focus again.

From a FocusScopeNode, calling set_first_focus sets the given focus scope as the focused_child of this node, adopting if it isn’t already part of the focus tree.

Implementations§

Source§

impl FocusScopeNode

Source

pub fn new(app: &mut App) -> Retained<Handle<FocusScopeNode>>

Creates a FocusScopeNode.

Dart’s optional constructor arguments are the setters; descendantsAreFocusable is always true on a scope, which is FocusNodeData’s default.

Source

pub fn traversal_edge_behavior( self: Handle<FocusScopeNode>, app: &App, ) -> TraversalEdgeBehavior

Source

pub fn set_traversal_edge_behavior( self: Handle<FocusScopeNode>, app: &mut App, value: TraversalEdgeBehavior, )

Source

pub fn directional_traversal_edge_behavior( self: Handle<FocusScopeNode>, app: &App, ) -> TraversalEdgeBehavior

Source

pub fn set_directional_traversal_edge_behavior( self: Handle<FocusScopeNode>, app: &mut App, value: TraversalEdgeBehavior, )

Source

pub fn is_first_focus(self: Handle<FocusScopeNode>, app: &mut App) -> bool

Returns true if this scope is the focused child of its parent scope.

Source

pub fn focused_child( self: Handle<FocusScopeNode>, app: &mut App, ) -> Option<AnyFocusNode>

Returns the child of this node that should receive focus if this scope node receives focus.

If has_focus is true, then this points to the child of this node that is currently focused.

Returns None if there is no currently focused child.

Source

pub fn set_first_focus( self: Handle<FocusScopeNode>, app: &mut App, scope: Handle<FocusScopeNode>, )

Make the given scope the active child scope for this scope.

If the given scope is not yet a part of the focus tree, then add it to the tree as a child of this scope. If it is already part of the focus tree, the given scope must be a descendant of this scope.

Source

pub fn autofocus( self: Handle<FocusScopeNode>, app: &mut App, node: AnyFocusNode, )

If this scope lacks a focus, request that the given node become the focus.

If the given node is not yet part of the focus tree, then add it as a child of this node.

Useful for widgets that wish to grab the focus if no other widget already has the focus.

The node is notified that it has received the primary focus in a microtask, so notification may lag the request by up to one frame.

Source

pub fn request_scope_focus(self: Handle<FocusScopeNode>, app: &mut App)

Requests that the scope itself receive focus, without trying to find a descendant that should receive focus.

This is used only if you want to park the focus on a scope itself.

Trait Implementations§

Source§

impl ChangeNotifier for FocusScopeNode

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.
Source§

impl FocusNodeLeaf for FocusScopeNode

Source§

fn traversal_children( self: Handle<FocusScopeNode>, app: &mut App, ) -> Vec<AnyFocusNode>

Will return an empty iterable if this scope node is not focusable, or if descendants_are_focusable is false.

Source§

fn traversal_descendants( self: Handle<FocusScopeNode>, app: &mut App, ) -> Vec<AnyFocusNode>

Will return an empty iterable if this scope node is not focusable, or if descendants_are_focusable is false.

Source§

fn focus_node_data(self: Handle<FocusScopeNode>, app: &App) -> &FocusNodeData

Dart’s FocusNode fields, held under the field focus_node (focus_node_accessors!).
Source§

fn focus_node_data_mut( self: Handle<FocusScopeNode>, app: &mut App, ) -> &mut FocusNodeData

Source§

fn as_scope(self: Handle<FocusScopeNode>) -> Option<Handle<FocusScopeNode>>

Dart’s node is FocusScopeNode.
Source§

fn nearest_scope( self: Handle<FocusScopeNode>, _app: &mut App, ) -> Option<Handle<FocusScopeNode>>

Returns the nearest enclosing scope node above this node, including this node, if it’s a scope.
Source§

fn descendants_are_focusable(self: Handle<FocusScopeNode>, app: &App) -> bool

If false, will disable focus for all of this node’s descendants.
Source§

fn debug_fill_properties( self: Handle<FocusScopeNode>, app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s FocusNode.debugFillProperties, which FocusScopeNode’s own body calls where Dart writes super.
Source§

fn do_request_focus( self: Handle<FocusScopeNode>, app: &mut App, find_first_focus: bool, )

Requests the primary focus for this node; overridden by FocusScopeNode.
Source§

fn as_node(self: Handle<Self>) -> AnyFocusNode

This node as the erased AnyFocusNode — what to pass where a Dart API takes a FocusNode. Read more
Source§

fn debug_describe_children( self: Handle<Self>, app: &mut App, ) -> Vec<Rc<dyn DiagnosticsNode>>

Dart’s FocusNode.debugDescribeChildren: each child, named Child 1, Child 2, ….
Source§

fn to_string_short(self: Handle<Self>, app: &App) -> String

Dart’s FocusNode.toStringShort: the identity, then the debug label and the focus markers.
Source§

fn skip_traversal(self: Handle<Self>, app: &mut App) -> bool

Source§

fn set_skip_traversal(self: Handle<Self>, app: &mut App, value: bool)

Source§

fn can_request_focus(self: Handle<Self>, app: &mut App) -> bool

Source§

fn set_can_request_focus(self: Handle<Self>, app: &mut App, value: bool)

Source§

fn set_descendants_are_focusable(self: Handle<Self>, app: &mut App, value: bool)

Source§

fn descendants_are_traversable(self: Handle<Self>, app: &App) -> bool

Source§

fn set_descendants_are_traversable( self: Handle<Self>, app: &mut App, value: bool, )

Source§

fn context(self: Handle<Self>, app: &App) -> Option<AnyElement>

Source§

fn on_key_event( self: Handle<Self>, app: &App, ) -> Option<Rc<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>>

Source§

fn set_on_key_event( self: Handle<Self>, app: &mut App, value: Option<Rc<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>>, )

Source§

fn debug_label(self: Handle<Self>, app: &App) -> Option<String>

Source§

fn set_debug_label(self: Handle<Self>, app: &mut App, value: Option<String>)

Source§

fn parent(self: Handle<Self>, app: &App) -> Option<AnyFocusNode>

Source§

fn children(self: Handle<Self>, app: &App) -> Vec<AnyFocusNode>

Source§

fn descendants(self: Handle<Self>, app: &mut App) -> Vec<AnyFocusNode>

Source§

fn ancestors(self: Handle<Self>, app: &mut App) -> Vec<AnyFocusNode>

Source§

fn has_focus(self: Handle<Self>, app: &mut App) -> bool

Source§

fn has_primary_focus(self: Handle<Self>, app: &App) -> bool

Source§

fn highlight_mode(self: Handle<Self>, app: &mut App) -> FocusHighlightMode

Source§

fn enclosing_scope( self: Handle<Self>, app: &mut App, ) -> Option<Handle<FocusScopeNode>>

Source§

fn size(self: Handle<Self>, app: &App) -> Size

Source§

fn offset(self: Handle<Self>, app: &App) -> Offset

Source§

fn rect(self: Handle<Self>, app: &App) -> Rect

Source§

fn unfocus(self: Handle<Self>, app: &mut App, disposition: UnfocusDisposition)

Source§

fn consume_keyboard_token(self: Handle<Self>, app: &mut App) -> bool

Source§

fn attach( self: Handle<Self>, app: &mut App, context: Option<AnyElement>, on_key_event: Option<Rc<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>>, ) -> Retained<Handle<FocusAttachment>>

Source§

fn dispose(self: Handle<Self>, app: &mut App)

Source§

fn request_focus(self: Handle<Self>, app: &mut App, node: Option<AnyFocusNode>)

Auto Trait Implementations§

§

impl !RefUnwindSafe for FocusScopeNode

§

impl !Send for FocusScopeNode

§

impl !Sync for FocusScopeNode

§

impl !UnwindSafe for FocusScopeNode

§

impl Forget for FocusScopeNode

§

impl Freeze for FocusScopeNode
where *const u8 is !null: Freeze, PhantomData<Option<Listener>>: Freeze, *const RcInner<Cell<usize>> is !null: Freeze, PhantomData<RcInner<Cell<usize>>>: Freeze, NonZero<u32>: Freeze, &'static ElementVTable: Freeze, *const RcInner<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>>: Freeze, PhantomData<fn() -> FocusManager>: Freeze, PhantomData<AnyFocusNode>: Freeze, PhantomData<Retained<AnyFocusNode>>: Freeze, &'static FocusNodeVTable: Freeze, PhantomData<u8>: Freeze, PhantomData<fn() -> FocusAttachment>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, PhantomData<fn() -> FocusScopeNode>: Freeze,

§

impl Move for FocusScopeNode

§

impl Unpin for FocusScopeNode
where *const u8 is !null: Unpin, Rc<dyn Fn(&mut App)>: Unpin, NonZero<u32>: Unpin, *const (): Unpin, Rc<Cell<usize>>: Unpin, &'static ElementVTable: Unpin, Rc<dyn Fn(&mut App, AnyFocusNode, &KeyEvent) -> KeyEventResult>: Unpin, &'static FocusNodeVTable: Unpin, Rc<Keep>: Unpin,

§

impl UnsafeUnpin for FocusScopeNode

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 for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
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>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more