pub struct AnyFocusNode { /* private fields */ }Expand description
Erased FocusNode: one identity and a static vtable, the fat pointer rustc cannot build
for an arena id. No lease.
This is what a field or parameter Dart types as FocusNode becomes; the leaf stays in the
App under its own type, and downcast gets the typed handle back.
The shared FocusNode members live here because a node reaches its parent, children, and
the primary focus through this handle.
Equality is Dart’s == on an object reference: two handles are equal exactly when they
address the same node.
Implementations§
Source§impl AnyFocusNode
impl AnyFocusNode
Sourcepub fn upgrade(self, app: &App) -> Option<Retained<AnyFocusNode>>
pub fn upgrade(self, app: &App) -> Option<Retained<AnyFocusNode>>
A reference while something still keeps the object, None once it is freed or
its last keeper has let go; see Handle::upgrade.
Sourcepub fn keep(self, app: &App) -> Retained<AnyFocusNode>
pub fn keep(self, app: &App) -> Retained<AnyFocusNode>
A reference to an object something is known to keep; see
Handle::keep.
Source§impl AnyFocusNode
impl AnyFocusNode
Sourcepub fn downcast<T: 'static>(self, app: &App) -> Option<Handle<T>>
pub fn downcast<T: 'static>(self, app: &App) -> Option<Handle<T>>
Dart’s node as T: the typed handle when this node is a T, else None.
Sourcepub fn debug_fill_properties(
self,
app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
pub fn debug_fill_properties( self, app: &App, properties: &mut DiagnosticPropertiesBuilder, )
Dart’s node.debugFillProperties: the node’s own properties, after Diagnosticable’s
none.
Sourcepub fn debug_describe_children(
self,
app: &mut App,
) -> Vec<Rc<dyn DiagnosticsNode>>
pub fn debug_describe_children( self, app: &mut App, ) -> Vec<Rc<dyn DiagnosticsNode>>
Dart’s node.debugDescribeChildren: the node’s children.
Sourcepub fn to_string_short(self, app: &App) -> String
pub fn to_string_short(self, app: &App) -> String
Dart’s node.toStringShort.
Sourcepub fn to_diagnostics_node(
self,
app: &mut App,
name: Option<String>,
) -> DiagnosticableTreeNode
pub fn to_diagnostics_node( self, app: &mut App, name: Option<String>, ) -> DiagnosticableTreeNode
Dart’s node.toDiagnosticsNode(name:): a snapshot of the node and its children.
Sourcepub fn to_string(self, app: &App) -> String
pub fn to_string(self, app: &App) -> String
Dart’s Diagnosticable.toString, which a property holding a node prints: its short
description, then the properties at the info level or above on one line.
Sourcepub fn as_scope(self) -> Option<Handle<FocusScopeNode>>
pub fn as_scope(self) -> Option<Handle<FocusScopeNode>>
Dart’s node is FocusScopeNode.
Sourcepub fn skip_traversal(self, app: &mut App) -> bool
pub fn skip_traversal(self, app: &mut App) -> bool
If true, tells the focus traversal policy to skip over this node for purposes of the traversal algorithm.
This may be used to place nodes in the focus tree that may be focused, but not traversed, allowing them to receive key events as part of the focus chain, but not be traversed to via focus traversal.
This is different from can_request_focus because it only
implies that the node can’t be reached via traversal, not that it can’t be focused. It
may still be focused explicitly.
Sourcepub fn set_skip_traversal(self, app: &mut App, value: bool)
pub fn set_skip_traversal(self, app: &mut App, value: bool)
See skip_traversal.
Sourcepub fn can_request_focus(self, app: &App) -> bool
pub fn can_request_focus(self, app: &App) -> bool
If true, this focus node may request the primary focus.
Defaults to true. Set to false if you want this node to do nothing when
request_focus is called on it.
If set to false on a FocusScopeNode, will cause all of the children of the scope
node to not be focusable.
If set to false on a FocusNode, it will not affect the focusability of children of
the node.
The has_focus member can still return true if this node is the
ancestor of a node with primary focus.
This is different than skip_traversal because
skip_traversal still allows the node to be focused, just not
traversed to via the FocusTraversalPolicy.
Setting can_request_focus to false implies that the node
will also be skipped for traversal purposes.
Sourcepub fn set_can_request_focus(self, app: &mut App, value: bool)
pub fn set_can_request_focus(self, app: &mut App, value: bool)
See can_request_focus.
Sourcepub fn descendants_are_focusable(self, app: &App) -> bool
pub fn descendants_are_focusable(self, app: &App) -> bool
If false, will disable focus for all of this node’s descendants.
Defaults to true. Does not affect focusability of this node: for that, use
can_request_focus.
If any descendants are focused when this is set to false, they will be unfocused. When
descendants_are_focusable is set to true again,
they will not be refocused, although they will be able to accept focus again.
Does not affect the value of can_request_focus on the
descendants.
If a descendant node loses focus when this value is changed, the focus will move to the scope enclosing this node.
Sourcepub fn set_descendants_are_focusable(self, app: &mut App, value: bool)
pub fn set_descendants_are_focusable(self, app: &mut App, value: bool)
Sourcepub fn descendants_are_traversable(self, app: &App) -> bool
pub fn descendants_are_traversable(self, app: &App) -> bool
If false, tells the focus traversal policy to skip over for all of this node’s descendants for purposes of the traversal algorithm.
Defaults to true. Does not affect the focus traversal of this node: for that, use
skip_traversal.
Does not affect the value of skip_traversal on the
descendants. Does not affect focusability of the descendants.
Sourcepub fn set_descendants_are_traversable(self, app: &mut App, value: bool)
pub fn set_descendants_are_traversable(self, app: &mut App, value: bool)
Sourcepub fn context(self, app: &App) -> Option<BuildContext>
pub fn context(self, app: &App) -> Option<BuildContext>
The context that was supplied to attach.
This is typically the context for the widget that is being focused, as it is used to determine the bounds of the widget.
Sourcepub fn on_key_event(self, app: &App) -> Option<FocusOnKeyEventCallback>
pub fn on_key_event(self, app: &App) -> Option<FocusOnKeyEventCallback>
Called if this focus node receives a key event while focused (i.e. when
has_focus returns true).
The FocusManager receives key events from HardwareKeyboard and will pass them to
the focused nodes. It starts with the node with the primary focus, and will call the
on_key_event callback for that node. If the callback returns
KeyEventResult::Ignored, indicating that it did not handle the event, the
FocusManager will move to the parent of that node and call its on_key_event. If
that on_key_event returns KeyEventResult::Handled, then it will stop propagating
the event. If it reaches the root FocusScopeNode, FocusManager::root_scope, the
event is discarded.
Sourcepub fn set_on_key_event(
self,
app: &mut App,
value: Option<FocusOnKeyEventCallback>,
)
pub fn set_on_key_event( self, app: &mut App, value: Option<FocusOnKeyEventCallback>, )
See on_key_event.
Sourcepub fn parent(self, app: &App) -> Option<AnyFocusNode>
pub fn parent(self, app: &App) -> Option<AnyFocusNode>
Returns the parent node for this object.
All nodes except for the root FocusScopeNode (FocusManager::root_scope) will be
given a parent when they are added to the focus tree, which is done using
FocusAttachment::reparent.
Sourcepub fn children(self, app: &App) -> Vec<AnyFocusNode>
pub fn children(self, app: &App) -> Vec<AnyFocusNode>
An iterator over the children of this node.
Sourcepub fn traversal_children(self, app: &mut App) -> Vec<AnyFocusNode>
pub fn traversal_children(self, app: &mut App) -> Vec<AnyFocusNode>
An iterator over the children that are allowed to be traversed by the
FocusTraversalPolicy.
Returns the list of focusable, traversable children of this node, regardless of those
settings on this focus node. Will return an empty iterable if
descendants_are_focusable is false.
Sourcepub fn debug_label(self, app: &App) -> Option<String>
pub fn debug_label(self, app: &App) -> Option<String>
A debug label that is used for diagnostic output.
Sourcepub fn set_debug_label(self, app: &mut App, value: Option<String>)
pub fn set_debug_label(self, app: &mut App, value: Option<String>)
See debug_label.
Sourcepub fn descendants(self, app: &mut App) -> Vec<AnyFocusNode>
pub fn descendants(self, app: &mut App) -> Vec<AnyFocusNode>
The hierarchy of children below this one, in depth-first order.
Sourcepub fn traversal_descendants(self, app: &mut App) -> Vec<AnyFocusNode>
pub fn traversal_descendants(self, app: &mut App) -> Vec<AnyFocusNode>
Returns all descendants which do not have the
skip_traversal and do have the
can_request_focus flag set.
Sourcepub fn ancestors(self, app: &mut App) -> Vec<AnyFocusNode>
pub fn ancestors(self, app: &mut App) -> Vec<AnyFocusNode>
The ancestors of this node.
Iterates the ancestors of this node starting at the parent and iterating over
successively more remote ancestors of this node, ending at the root FocusScopeNode
(FocusManager::root_scope).
Sourcepub fn has_focus(self, app: &App) -> bool
pub fn has_focus(self, app: &App) -> bool
Whether this node has input focus.
A FocusNode has focus when it is an ancestor of a node that returns true from
has_primary_focus, or it has the primary focus itself.
The has_focus accessor is different from
has_primary_focus in that
has_focus is true if the node is anywhere in the focus chain, but
for has_primary_focus the node must be at the end of the
chain to return true.
Sourcepub fn has_primary_focus(self, app: &App) -> bool
pub fn has_primary_focus(self, app: &App) -> bool
Returns true if this node currently has the application-wide input focus.
A FocusNode has the primary focus when the node is focused in its nearest ancestor
FocusScopeNode and has_focus is true for all its ancestor
nodes, but none of its descendants.
Sourcepub fn highlight_mode(self, app: &mut App) -> FocusHighlightMode
pub fn highlight_mode(self, app: &mut App) -> FocusHighlightMode
Returns the FocusHighlightMode that is currently in effect for this node.
Sourcepub fn nearest_scope(self, app: &mut App) -> Option<Handle<FocusScopeNode>>
pub fn nearest_scope(self, app: &mut App) -> Option<Handle<FocusScopeNode>>
Returns the nearest enclosing scope node above this node, including this node, if it’s a scope.
Returns None if no scope is found.
Use enclosing_scope to look for scopes above this node.
Sourcepub fn enclosing_scope(self, app: &mut App) -> Option<Handle<FocusScopeNode>>
pub fn enclosing_scope(self, app: &mut App) -> Option<Handle<FocusScopeNode>>
Returns the nearest enclosing scope node above this node, or None if the node has not
yet been added to the focus tree.
If this node is itself a scope, this will only return ancestors of this scope.
Use nearest_scope to start at this node instead of above it.
Sourcepub fn size(self, app: &App) -> Size
pub fn size(self, app: &App) -> Size
Returns the size of the attached widget’s RenderObject, in logical units.
Size is the size of the transformed widget in global coordinates.
Sourcepub fn offset(self, app: &App) -> Offset
pub fn offset(self, app: &App) -> Offset
Returns the global offset to the upper left corner of the attached widget’s
RenderObject, in logical units.
Offset is the offset of the transformed widget in global coordinates.
Sourcepub fn rect(self, app: &App) -> Rect
pub fn rect(self, app: &App) -> Rect
Returns the global rectangle of the attached widget’s RenderObject, in logical units.
Rect is the rectangle of the transformed widget in global coordinates.
Sourcepub fn unfocus(self, app: &mut App, disposition: UnfocusDisposition)
pub fn unfocus(self, app: &mut App, disposition: UnfocusDisposition)
Removes the focus on this node by moving the primary focus to another node.
This method removes focus from a node that has the primary focus, cancels any
outstanding requests to focus it, while setting the primary focus to another node
according to the disposition.
It is safe to call regardless of whether this node has ever requested focus or not. If this node doesn’t have focus or primary focus, nothing happens.
If disposition is UnfocusDisposition::Scope, then the previously focused node
history of the enclosing scope will be cleared, and the primary focus will be moved to
the nearest enclosing scope ancestor that is enabled for focus, ignoring the
FocusScopeNode::focused_child for that scope.
If disposition is UnfocusDisposition::PreviouslyFocusedChild, then this node will
be removed from the previously focused list in the
enclosing_scope, and the focus will be moved to the
previously focused node of the enclosing_scope, which (if it
is a scope itself), will find its focused child, etc., until a leaf focus node is found.
If there is no previously focused child, then the scope itself will receive focus, as if
UnfocusDisposition::Scope were specified.
Sourcepub fn consume_keyboard_token(self, app: &mut App) -> bool
pub fn consume_keyboard_token(self, app: &mut App) -> bool
Removes the keyboard token from this focus node if it has one.
This mechanism helps distinguish between an input control gaining focus by default and gaining focus as a result of an explicit user action.
When a focus node requests the focus (either via
request_focus or FocusScopeNode::autofocus), the focus node
receives a keyboard token if it does not already have one. Later, when the focus node
becomes focused, the widget that manages the text input connection should show the
keyboard only if it successfully consumes the keyboard token from the focus node.
Returns true if this method successfully consumes the keyboard token.
Sourcepub fn attach(
self,
app: &mut App,
context: Option<BuildContext>,
on_key_event: Option<FocusOnKeyEventCallback>,
) -> Ref<FocusAttachment>
pub fn attach( self, app: &mut App, context: Option<BuildContext>, on_key_event: Option<FocusOnKeyEventCallback>, ) -> Ref<FocusAttachment>
Called by the host StatefulWidget to attach a FocusNode to the widget tree.
In order to attach a FocusNode to the widget tree, call
attach, typically from the StatefulWidget’s State::init_state
method.
If the focus node in the host widget is swapped out, the new node will need to be
attached. FocusAttachment::detach should be called on the old node, and then
attach called on the new node. This typically happens in the
State::did_update_widget method.
Sourcepub fn dispose(self, app: &mut App)
pub fn dispose(self, app: &mut App)
Discards any resources used by this node.
Detaching also unfocuses and cleans up the manager’s data structures.
Sourcepub fn request_focus(self, app: &mut App, node: Option<AnyFocusNode>)
pub fn request_focus(self, app: &mut App, node: Option<AnyFocusNode>)
Requests the primary focus for this node, or for a supplied node, which will also give
focus to its ancestors.
If called without a node, request focus for this node. If the node hasn’t been added to the focus tree yet, then defer the focus request until it is, allowing newly created widgets to request focus as soon as they are added.
If the given node is not yet a part of the focus tree, then this method will add the
node as a child of this node before requesting focus.
If the given node is a FocusScopeNode and that focus scope node has a non-null
FocusScopeNode::focused_child, then request the focus for the focused child. This
process is recursive and continues until it encounters either a focus scope node with a
null focused child or an ordinary (non-scope) FocusNode is found.
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 next_focus(self, app: &mut App) -> bool
pub fn next_focus(self, app: &mut App) -> bool
Request to move the focus to the next focus node, by calling the
FocusTraversalPolicy::next method.
Returns true if it successfully found a node and requested focus.
Sourcepub fn previous_focus(self, app: &mut App) -> bool
pub fn previous_focus(self, app: &mut App) -> bool
Request to move the focus to the previous focus node, by calling the
FocusTraversalPolicy::previous method.
Returns true if it successfully found a node and requested focus.
Sourcepub fn focus_in_direction(
self,
app: &mut App,
direction: TraversalDirection,
) -> bool
pub fn focus_in_direction( self, app: &mut App, direction: TraversalDirection, ) -> bool
Request to move the focus to the nearest focus node in the given direction, by calling
the FocusTraversalPolicy::in_direction method.
Returns true if it successfully found a node and requested focus.
Sourcepub fn add_listener(self, app: &mut App, listener: Listener)
pub fn add_listener(self, app: &mut App, listener: Listener)
Register a closure to be called when this node notifies its listeners.
Sourcepub fn remove_listener(self, app: &mut App, listener: &Listener)
pub fn remove_listener(self, app: &mut App, listener: &Listener)
Remove a previously registered closure from the list of closures this node notifies.
Trait Implementations§
Source§impl Clone for AnyFocusNode
impl Clone for AnyFocusNode
impl Copy for AnyFocusNode
Source§impl Debug for AnyFocusNode
impl Debug for AnyFocusNode
impl Eq for AnyFocusNode
Source§impl From<AnyFocusNode> for HandleId
impl From<AnyFocusNode> for HandleId
Source§fn from(handle: AnyFocusNode) -> HandleId
fn from(handle: AnyFocusNode) -> HandleId
Source§impl<Leaf: FocusNodeLeaf> From<Handle<Leaf>> for AnyFocusNode
impl<Leaf: FocusNodeLeaf> From<Handle<Leaf>> for AnyFocusNode
Source§fn from(handle: Handle<Leaf>) -> AnyFocusNode
fn from(handle: Handle<Leaf>) -> AnyFocusNode
Source§impl Hash for AnyFocusNode
impl Hash for AnyFocusNode
Source§impl ListenableHandle for AnyFocusNode
impl ListenableHandle for AnyFocusNode
Source§fn add_listener_to(self, app: &mut App, listener: Listener)
fn add_listener_to(self, app: &mut App, listener: Listener)
Source§fn remove_listener_from(self, app: &mut App, listener: &Listener)
fn remove_listener_from(self, app: &mut App, listener: &Listener)
Source§impl PartialEq for AnyFocusNode
impl PartialEq for AnyFocusNode
Source§impl PartialEq<AnyFocusNode> for &Retained<AnyFocusNode>
impl PartialEq<AnyFocusNode> for &Retained<AnyFocusNode>
Auto Trait Implementations§
impl Forget for AnyFocusNode
impl Freeze for AnyFocusNode
impl Move for AnyFocusNode
impl RefUnwindSafe for AnyFocusNode
impl Send for AnyFocusNode
impl Sync for AnyFocusNode
impl Unpin for AnyFocusNode
impl UnsafeUnpin for AnyFocusNodewhere
NonZeroU32Inner: UnsafeUnpin,
&'static FocusNodeVTable: UnsafeUnpin,
impl UnwindSafe for AnyFocusNode
Blanket Implementations§
Source§impl<T> AnyEq for T
impl<T> AnyEq for T
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.