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>See Widget::key.
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:
FocusTraversalPolicyfor the API used to impose traversal order policy.WidgetOrderTraversalPolicyfor a traversal policy that traverses nodes in the order they are added to the widget tree.ReadingOrderTraversalPolicyfor a traversal policy that traverses nodes in the reading order defined in the widget tree, and then top to bottom.
descendants_are_focusable: boolIf false, will make this widget’s descendants unfocusable.
descendants_are_traversable: boolIf 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: WidgetRefThe child widget of this FocusTraversalGroup.
Implementations§
Source§impl FocusTraversalGroup
impl FocusTraversalGroup
Sourcepub fn new<K>(child: impl IntoWidget<K>) -> FocusTraversalGroup
pub fn new<K>(child: impl IntoWidget<K>) -> FocusTraversalGroup
Creates a FocusTraversalGroup.
Sourcepub fn key(self, key: KeyRef) -> FocusTraversalGroup
pub fn key(self, key: KeyRef) -> FocusTraversalGroup
Dart FocusTraversalGroup(key:).
Sourcepub fn policy(self, policy: FocusTraversalPolicyRef) -> FocusTraversalGroup
pub fn policy(self, policy: FocusTraversalPolicyRef) -> FocusTraversalGroup
Dart FocusTraversalGroup(policy:).
Sourcepub fn descendants_are_focusable(
self,
descendants_are_focusable: bool,
) -> FocusTraversalGroup
pub fn descendants_are_focusable( self, descendants_are_focusable: bool, ) -> FocusTraversalGroup
Dart FocusTraversalGroup(descendantsAreFocusable:).
Sourcepub fn descendants_are_traversable(
self,
descendants_are_traversable: bool,
) -> FocusTraversalGroup
pub fn descendants_are_traversable( self, descendants_are_traversable: bool, ) -> FocusTraversalGroup
Dart FocusTraversalGroup(descendantsAreTraversable:).
Sourcepub fn on_focus_node_created(
self,
on_focus_node_created: impl Fn(&mut App, AnyFocusNode) + 'static,
) -> FocusTraversalGroup
pub fn on_focus_node_created( self, on_focus_node_created: impl Fn(&mut App, AnyFocusNode) + 'static, ) -> FocusTraversalGroup
Dart FocusTraversalGroup(onFocusNodeCreated:).
Sourcepub fn parent_node(self, parent_node: FocusNodeRef) -> FocusTraversalGroup
pub fn parent_node(self, parent_node: FocusNodeRef) -> FocusTraversalGroup
Dart FocusTraversalGroup(parentNode:).
Sourcepub fn maybe_of_node(
app: &App,
node: AnyFocusNode,
) -> Option<AnyFocusTraversalPolicy>
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.
Sourcepub fn of(app: &mut App, context: BuildContext) -> AnyFocusTraversalPolicy
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_offor a similar function that will returnNoneif noFocusTraversalGroupancestor is found.maybe_of_nodefor a function that will look for a policy using a givenFocusNode, and returnNoneif no policy applies.
Sourcepub fn maybe_of(
app: &mut App,
context: BuildContext,
) -> Option<AnyFocusTraversalPolicy>
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:
maybe_of_nodefor a similar function that will look for a policy using a givenFocusNode.offor a similar function that will panic if noFocusTraversalPolicyapplies.
Trait Implementations§
Source§impl Debug for FocusTraversalGroup
impl Debug for FocusTraversalGroup
Source§impl StatefulWidget for FocusTraversalGroup
impl StatefulWidget for FocusTraversalGroup
Source§type State = FocusTraversalGroupState
type State = FocusTraversalGroupState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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
fn create_state(&self) -> FocusTraversalGroupState
Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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 FocusTraversalGroupwhere
*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
impl UnsafeUnpin for FocusTraversalGroupwhere
*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> 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<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.