Skip to main content

FocusTraversalGroup

Struct FocusTraversalGroup 

Source
pub struct FocusTraversalGroup {
    pub key: Option<KeyRef>,
    pub policy: Option<FocusTraversalPolicyRef>,
    pub descendants_are_focusable: bool,
    pub descendants_are_traversable: bool,
    pub on_focus_node_created: Option<ValueChanged<AnyFocusNode>>,
    pub parent_node: Option<FocusNodeRef>,
    pub child: WidgetRef,
}
Expand description

A widget that describes the inherited focus policy for focus traversal for its descendants, grouping them into a separate traversal group.

A traversal group is treated as one entity when sorted by the traversal algorithm, so it can be used to segregate different parts of the widget tree that need to be sorted using different algorithms and/or sort orders when using an OrderedTraversalPolicy.

Within the group, it will use the given policy to order the elements. The group itself will be ordered using the parent group’s policy.

By default, traverses in reading order using ReadingOrderTraversalPolicy.

To prevent the members of the group from being focused, set the descendants_are_focusable attribute to false.

Fields§

§key: Option<KeyRef>§policy: Option<FocusTraversalPolicyRef>

The policy used to move the focus from one focus node to another when traversing them using a keyboard.

If not specified, traverses in reading order using ReadingOrderTraversalPolicy, which the state creates, since a policy is an arena object a widget cannot mint.

See also:

§descendants_are_focusable: bool

If false, will make this widget’s descendants unfocusable.

§descendants_are_traversable: bool

If false, will make this widget’s descendants untraversable.

§on_focus_node_created: Option<ValueChanged<AnyFocusNode>>

Called when the FocusNode of this widget is created.

§parent_node: Option<FocusNodeRef>

The optional parent node to use when reparenting this group’s FocusNode.

If None, the enclosing FocusScope is used as the parent, which mirrors the widget tree and is typically what is desired.

Setting this attaches the group (and the focus subtree below it) to the given node instead of the enclosing FocusScope, which is useful to keep a subtree’s focus independent from the surrounding focus tree (for example, so each View forms its own focus root).

Defaults to None.

§child: WidgetRef

The child widget of this FocusTraversalGroup.

Implementations§

Source§

impl FocusTraversalGroup

Source

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

Source

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

Dart FocusTraversalGroup(key:).

Source

pub fn policy(self, policy: FocusTraversalPolicyRef) -> FocusTraversalGroup

Dart FocusTraversalGroup(policy:).

Source

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

Dart FocusTraversalGroup(descendantsAreFocusable:).

Source

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

Dart FocusTraversalGroup(descendantsAreTraversable:).

Source

pub fn on_focus_node_created( self, on_focus_node_created: impl Fn(&mut App, AnyFocusNode) + 'static, ) -> FocusTraversalGroup

Dart FocusTraversalGroup(onFocusNodeCreated:).

Source

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

Dart FocusTraversalGroup(parentNode:).

Source

pub fn maybe_of_node( app: &App, node: AnyFocusNode, ) -> Option<AnyFocusTraversalPolicy>

Returns the FocusTraversalPolicy that applies to the nearest ancestor of the given FocusNode.

Will return None if no FocusTraversalPolicy ancestor applies to the given FocusNode.

The FocusTraversalPolicy is set by introducing a FocusTraversalGroup into the widget tree, which will associate a policy with the focus tree under the nearest ancestor Focus widget.

This function differs from maybe_of in that it takes a FocusNode and only traverses the focus tree to determine the policy in effect.

Source

pub fn of(app: &mut App, context: BuildContext) -> AnyFocusTraversalPolicy

Returns the FocusTraversalPolicy that applies to the FocusNode of the nearest ancestor Focus widget, given a BuildContext.

Panics if no Focus ancestor is found, or if no FocusTraversalPolicy applies to the associated FocusNode.

This function looks up the nearest ancestor Focus (or FocusScope) widget, and uses its FocusNode to walk up the focus tree to find the applicable FocusTraversalPolicy for that node.

Calling this function does not create a rebuild dependency because changing the traversal order doesn’t change the widget tree, so nothing needs to be rebuilt as a result of an order change.

See also:

  • maybe_of for a similar function that will return None if no FocusTraversalGroup ancestor is found.
  • maybe_of_node for a function that will look for a policy using a given FocusNode, and return None if no policy applies.
Source

pub fn maybe_of( app: &mut App, context: BuildContext, ) -> Option<AnyFocusTraversalPolicy>

Returns the FocusTraversalPolicy that applies to the FocusNode of the nearest ancestor Focus widget, or None, given a BuildContext.

See also:

Trait Implementations§

Source§

impl Debug for FocusTraversalGroup

Source§

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

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

impl StatefulWidget for FocusTraversalGroup

Source§

type State = FocusTraversalGroupState

The state this widget creates.
Source§

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

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 create_state(&self) -> FocusTraversalGroupState

Creates the mutable state for this widget at a given location in the tree. Read more
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 FocusTraversalGroup

§

impl !Send for FocusTraversalGroup

§

impl !Sync for FocusTraversalGroup

§

impl !UnwindSafe for FocusTraversalGroup

§

impl Forget for FocusTraversalGroup

§

impl Freeze for FocusTraversalGroup
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, &'static FocusTraversalPolicyVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyFocusNode)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode)>>: Freeze, &'static FocusNodeVTable: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for FocusTraversalGroup

§

impl Unpin for FocusTraversalGroup
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, &'static FocusTraversalPolicyVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&mut App, AnyFocusNode)>: Unpin, &'static FocusNodeVTable: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for FocusTraversalGroup
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static FocusTraversalPolicyVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyFocusNode)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode)>>: UnsafeUnpin, &'static FocusNodeVTable: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: 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>