Skip to main content

AnyFocusNode

Struct AnyFocusNode 

Source
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

Source

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.

Source

pub fn keep(self, app: &App) -> Retained<AnyFocusNode>

A reference to an object something is known to keep; see Handle::keep.

Source§

impl AnyFocusNode

Source

pub fn id(self) -> HandleId

The arena id behind this handle.

Source

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.

Source

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

Dart’s node.debugFillProperties: the node’s own properties, after Diagnosticable’s none.

Source

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

Dart’s node.debugDescribeChildren: the node’s children.

Source

pub fn to_string_short(self, app: &App) -> String

Dart’s node.toStringShort.

Source

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.

Source

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.

Source

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

Dart’s node is FocusScopeNode.

Source

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.

Source

pub fn set_skip_traversal(self, app: &mut App, value: bool)

Source

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.

Source

pub fn set_can_request_focus(self, app: &mut App, value: bool)

Source

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.

Source

pub fn set_descendants_are_focusable(self, app: &mut App, value: bool)

Source

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.

Source

pub fn set_descendants_are_traversable(self, app: &mut App, value: bool)

Source

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.

Source

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.

Source

pub fn set_on_key_event( self, app: &mut App, value: Option<FocusOnKeyEventCallback>, )

Source

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.

Source

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

An iterator over the children of this node.

Source

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.

Source

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

A debug label that is used for diagnostic output.

Source

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

Source

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

The hierarchy of children below this one, in depth-first order.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn highlight_mode(self, app: &mut App) -> FocusHighlightMode

Returns the FocusHighlightMode that is currently in effect for this node.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn add_listener(self, app: &mut App, listener: Listener)

Register a closure to be called when this node notifies its listeners.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AnyFocusNode

Source§

impl Debug for AnyFocusNode

Source§

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

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

impl Eq for AnyFocusNode

Source§

impl From<AnyFocusNode> for HandleId

Source§

fn from(handle: AnyFocusNode) -> HandleId

Converts to this type from the input type.
Source§

impl<Leaf: FocusNodeLeaf> From<Handle<Leaf>> for AnyFocusNode

Source§

fn from(handle: Handle<Leaf>) -> AnyFocusNode

Converts to this type from the input type.
Source§

impl Hash for AnyFocusNode

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl ListenableHandle for AnyFocusNode

Source§

impl PartialEq for AnyFocusNode

Source§

fn eq(&self, other: &AnyFocusNode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<AnyFocusNode> for &Retained<AnyFocusNode>

Source§

fn eq(&self, other: &AnyFocusNode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<Retained<AnyFocusNode>> for AnyFocusNode

Source§

fn eq(&self, other: &Retained<AnyFocusNode>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for AnyFocusNode

§

impl Freeze for AnyFocusNode
where NonZero<u32>: Freeze, &'static FocusNodeVTable: Freeze,

§

impl Move for AnyFocusNode

§

impl RefUnwindSafe for AnyFocusNode

§

impl Send for AnyFocusNode
where NonZero<u32>: Send, &'static FocusNodeVTable: Send,

§

impl Sync for AnyFocusNode
where NonZero<u32>: Sync,

§

impl Unpin for AnyFocusNode
where NonZero<u32>: Unpin, &'static FocusNodeVTable: Unpin,

§

impl UnsafeUnpin for AnyFocusNode
where NonZeroU32Inner: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin,

§

impl UnwindSafe for AnyFocusNode
where NonZero<u32>: UnwindSafe, &'static FocusNodeVTable: UnwindSafe,

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> AnyEq for T
where T: PartialEq + Hash + Debug + 'static,

Source§

fn eq_any(&self, other: &(dyn AnyEq + 'static)) -> bool

Dart’s operator ==. Must return false when other is a different concrete type, even if the two carry the same value.
Source§

fn hash_any(&self, state: &mut dyn Hasher)

Dart’s hashCode. Must mix in the concrete type so that two types carrying the same value do not collide.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SlotValue for T
where T: Clone + Eq + Hash + Debug + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,