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
impl FocusScopeNode
Sourcepub fn new(app: &mut App) -> Ref<FocusScopeNode>
pub fn new(app: &mut App) -> Ref<FocusScopeNode>
Creates a FocusScopeNode.
Dart’s optional constructor arguments are the setters; descendantsAreFocusable is
always true on a scope, which is FocusNodeData’s default.
Sourcepub fn traversal_edge_behavior(
self: Handle<Self>,
app: &App,
) -> TraversalEdgeBehavior
pub fn traversal_edge_behavior( self: Handle<Self>, app: &App, ) -> TraversalEdgeBehavior
Sourcepub fn set_traversal_edge_behavior(
self: Handle<Self>,
app: &mut App,
value: TraversalEdgeBehavior,
)
pub fn set_traversal_edge_behavior( self: Handle<Self>, app: &mut App, value: TraversalEdgeBehavior, )
Sourcepub fn directional_traversal_edge_behavior(
self: Handle<Self>,
app: &App,
) -> TraversalEdgeBehavior
pub fn directional_traversal_edge_behavior( self: Handle<Self>, app: &App, ) -> TraversalEdgeBehavior
Sourcepub fn set_directional_traversal_edge_behavior(
self: Handle<Self>,
app: &mut App,
value: TraversalEdgeBehavior,
)
pub fn set_directional_traversal_edge_behavior( self: Handle<Self>, app: &mut App, value: TraversalEdgeBehavior, )
Sourcepub fn is_first_focus(self: Handle<Self>, app: &mut App) -> bool
pub fn is_first_focus(self: Handle<Self>, app: &mut App) -> bool
Returns true if this scope is the focused child of its parent scope.
Sourcepub fn focused_child(self: Handle<Self>, app: &mut App) -> Option<AnyFocusNode>
pub fn focused_child(self: Handle<Self>, 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.
Sourcepub fn set_first_focus(
self: Handle<Self>,
app: &mut App,
scope: Handle<FocusScopeNode>,
)
pub fn set_first_focus( self: Handle<Self>, 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.
Sourcepub fn autofocus(self: Handle<Self>, app: &mut App, node: AnyFocusNode)
pub fn autofocus(self: Handle<Self>, 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.
Sourcepub fn request_scope_focus(self: Handle<Self>, app: &mut App)
pub fn request_scope_focus(self: Handle<Self>, 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
impl ChangeNotifier for FocusScopeNode
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.Source§impl FocusNodeLeaf for FocusScopeNode
impl FocusNodeLeaf for FocusScopeNode
Source§fn traversal_children(self: Handle<Self>, app: &mut App) -> Vec<AnyFocusNode>
fn traversal_children(self: Handle<Self>, 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<Self>, app: &mut App) -> Vec<AnyFocusNode>
fn traversal_descendants(self: Handle<Self>, 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<Self>, app: &App) -> &FocusNodeData
fn focus_node_data(self: Handle<Self>, app: &App) -> &FocusNodeData
Source§fn focus_node_data_mut(self: Handle<Self>, app: &mut App) -> &mut FocusNodeData
fn focus_node_data_mut(self: Handle<Self>, app: &mut App) -> &mut FocusNodeData
focus_node_data.Source§fn as_scope(self: Handle<Self>) -> Option<Handle<FocusScopeNode>>
fn as_scope(self: Handle<Self>) -> Option<Handle<FocusScopeNode>>
node is FocusScopeNode.Source§fn nearest_scope(
self: Handle<Self>,
_app: &mut App,
) -> Option<Handle<FocusScopeNode>>
fn nearest_scope( self: Handle<Self>, _app: &mut App, ) -> Option<Handle<FocusScopeNode>>
Source§fn descendants_are_focusable(self: Handle<Self>, app: &App) -> bool
fn descendants_are_focusable(self: Handle<Self>, app: &App) -> bool
Source§fn debug_fill_properties(
self: Handle<Self>,
app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( self: Handle<Self>, app: &App, properties: &mut DiagnosticPropertiesBuilder, )
FocusNode.debugFillProperties, which FocusScopeNode’s own body calls where
Dart writes super.Source§fn do_request_focus(self: Handle<Self>, app: &mut App, find_first_focus: bool)
fn do_request_focus(self: Handle<Self>, app: &mut App, find_first_focus: bool)
FocusScopeNode.Source§fn as_node(self: Handle<Self>) -> AnyFocusNode
fn as_node(self: Handle<Self>) -> AnyFocusNode
Source§fn debug_describe_children(
self: Handle<Self>,
app: &mut App,
) -> Vec<Rc<dyn DiagnosticsNode>>
fn debug_describe_children( self: Handle<Self>, app: &mut App, ) -> Vec<Rc<dyn DiagnosticsNode>>
FocusNode.debugDescribeChildren: each child, named Child 1, Child 2, ….Source§fn to_string_short(self: Handle<Self>, app: &App) -> String
fn to_string_short(self: Handle<Self>, app: &App) -> String
FocusNode.toStringShort: the identity, then the debug label and the focus
markers.Source§fn on_key_event(
self: Handle<Self>,
app: &App,
) -> Option<FocusOnKeyEventCallback>
fn on_key_event( self: Handle<Self>, app: &App, ) -> Option<FocusOnKeyEventCallback>
Source§fn set_on_key_event(
self: Handle<Self>,
app: &mut App,
value: Option<FocusOnKeyEventCallback>,
)
fn set_on_key_event( self: Handle<Self>, app: &mut App, value: Option<FocusOnKeyEventCallback>, )
Source§fn parent(self: Handle<Self>, app: &App) -> Option<AnyFocusNode>
fn parent(self: Handle<Self>, app: &App) -> Option<AnyFocusNode>
AnyFocusNode::parent.Source§fn descendants(self: Handle<Self>, app: &mut App) -> Vec<AnyFocusNode>
fn descendants(self: Handle<Self>, app: &mut App) -> Vec<AnyFocusNode>
Source§fn highlight_mode(self: Handle<Self>, app: &mut App) -> FocusHighlightMode
fn highlight_mode(self: Handle<Self>, app: &mut App) -> FocusHighlightMode
Source§fn enclosing_scope(
self: Handle<Self>,
app: &mut App,
) -> Option<Handle<FocusScopeNode>>
fn enclosing_scope( self: Handle<Self>, app: &mut App, ) -> Option<Handle<FocusScopeNode>>
Source§fn attach(
self: Handle<Self>,
app: &mut App,
context: Option<BuildContext>,
on_key_event: Option<FocusOnKeyEventCallback>,
) -> Ref<FocusAttachment>
fn attach( self: Handle<Self>, app: &mut App, context: Option<BuildContext>, on_key_event: Option<FocusOnKeyEventCallback>, ) -> Ref<FocusAttachment>
AnyFocusNode::attach.