pub struct ReadingOrderTraversalPolicy { /* private fields */ }Expand description
Traverses the focus order in “reading order”.
By default, reading order traversal goes in the reading direction, and then down, using this algorithm:
- Find the node rectangle that has the highest
topon the screen. - Find any other nodes that intersect the infinite horizontal band defined by the highest rectangle’s top and bottom edges.
- Pick the closest to the beginning of the reading order from among the nodes discovered above.
It uses the ambient Directionality in the context for the enclosing
FocusTraversalGroup to determine which direction is “reading order”.
Implementations§
Source§impl ReadingOrderTraversalPolicy
impl ReadingOrderTraversalPolicy
Sourcepub fn new(app: &mut App) -> Ref<ReadingOrderTraversalPolicy>
pub fn new(app: &mut App) -> Ref<ReadingOrderTraversalPolicy>
Constructs a traversal policy that orders the widgets in “reading order”.
Dart’s optional requestFocusCallback argument is
FocusTraversalPolicy::set_request_focus_callback.
Sourcepub fn sort(app: &App, nodes: Vec<AnyFocusNode>) -> Vec<AnyFocusNode>
pub fn sort(app: &App, nodes: Vec<AnyFocusNode>) -> Vec<AnyFocusNode>
Sorts the input focus nodes into reading order.
Trait Implementations§
Source§impl DirectionalFocusTraversalPolicyMixin for ReadingOrderTraversalPolicy
impl DirectionalFocusTraversalPolicyMixin for ReadingOrderTraversalPolicy
Source§fn directional_data(
self: Handle<Self>,
app: &App,
) -> &DirectionalFocusTraversalPolicyMixinData
fn directional_data( self: Handle<Self>, app: &App, ) -> &DirectionalFocusTraversalPolicyMixinData
Dart’s
DirectionalFocusTraversalPolicyMixin fields, held under the field directional.Source§fn directional_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut DirectionalFocusTraversalPolicyMixinData
fn directional_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut DirectionalFocusTraversalPolicyMixinData
See
directional_data.Source§fn invalidate_scope_data(
self: Handle<Self>,
app: &mut App,
node: Handle<FocusScopeNode>,
)
fn invalidate_scope_data( self: Handle<Self>, app: &mut App, node: Handle<FocusScopeNode>, )
Dart’s
DirectionalFocusTraversalPolicyMixin.invalidateScopeData.Source§fn changed_scope(
self: Handle<Self>,
app: &mut App,
node: Option<AnyFocusNode>,
old_scope: Option<Handle<FocusScopeNode>>,
)
fn changed_scope( self: Handle<Self>, app: &mut App, node: Option<AnyFocusNode>, old_scope: Option<Handle<FocusScopeNode>>, )
Dart’s
DirectionalFocusTraversalPolicyMixin.changedScope.Source§fn find_first_focus_in_direction(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
direction: TraversalDirection,
) -> Option<AnyFocusNode>
fn find_first_focus_in_direction( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, direction: TraversalDirection, ) -> Option<AnyFocusNode>
Dart’s
DirectionalFocusTraversalPolicyMixin.findFirstFocusInDirection.Source§fn find_next_focus_in_direction(
self: Handle<Self>,
app: &mut App,
focused_child: AnyFocusNode,
traversal_descendants: Vec<AnyFocusNode>,
direction: TraversalDirection,
forward: bool,
) -> Option<AnyFocusNode>
fn find_next_focus_in_direction( self: Handle<Self>, app: &mut App, focused_child: AnyFocusNode, traversal_descendants: Vec<AnyFocusNode>, direction: TraversalDirection, forward: bool, ) -> Option<AnyFocusNode>
Dart’s
DirectionalFocusTraversalPolicyMixin._findNextFocusInDirection.Source§fn pop_policy_data_if_needed(
self: Handle<Self>,
app: &mut App,
direction: TraversalDirection,
nearest_scope: Handle<FocusScopeNode>,
group_node: Option<Handle<FocusTraversalGroupNode>>,
) -> bool
fn pop_policy_data_if_needed( self: Handle<Self>, app: &mut App, direction: TraversalDirection, nearest_scope: Handle<FocusScopeNode>, group_node: Option<Handle<FocusTraversalGroupNode>>, ) -> bool
Updates the policy data to keep the previously visited node so that we can avoid
hysteresis when we change directions in navigation. Read more
Source§fn pop_or_invalidate(
self: Handle<Self>,
app: &mut App,
direction: TraversalDirection,
nearest_scope: Handle<FocusScopeNode>,
group_node: Option<Handle<FocusTraversalGroupNode>>,
) -> bool
fn pop_or_invalidate( self: Handle<Self>, app: &mut App, direction: TraversalDirection, nearest_scope: Handle<FocusScopeNode>, group_node: Option<Handle<FocusTraversalGroupNode>>, ) -> bool
Dart’s
popOrInvalidate closure inside _popPolicyDataIfNeeded. Returns true if it
successfully popped the history.Source§fn push_policy_data(
self: Handle<Self>,
app: &mut App,
direction: TraversalDirection,
nearest_scope: Handle<FocusScopeNode>,
focused_child: AnyFocusNode,
)
fn push_policy_data( self: Handle<Self>, app: &mut App, direction: TraversalDirection, nearest_scope: Handle<FocusScopeNode>, focused_child: AnyFocusNode, )
Dart’s
DirectionalFocusTraversalPolicyMixin._pushPolicyData.Source§fn request_traversal_focus_in_direction(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
node: AnyFocusNode,
nearest_scope: Handle<FocusScopeNode>,
direction: TraversalDirection,
group_node: Option<Handle<FocusTraversalGroupNode>>,
) -> bool
fn request_traversal_focus_in_direction( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, node: AnyFocusNode, nearest_scope: Handle<FocusScopeNode>, direction: TraversalDirection, group_node: Option<Handle<FocusTraversalGroupNode>>, ) -> bool
Dart’s
DirectionalFocusTraversalPolicyMixin._requestTraversalFocusInDirection.Source§fn request_focus(
self: Handle<Self>,
app: &mut App,
node: AnyFocusNode,
alignment_policy: Option<ScrollPositionAlignmentPolicy>,
group_node: Option<Handle<FocusTraversalGroupNode>>,
)
fn request_focus( self: Handle<Self>, app: &mut App, node: AnyFocusNode, alignment_policy: Option<ScrollPositionAlignmentPolicy>, group_node: Option<Handle<FocusTraversalGroupNode>>, )
Dart’s
DirectionalFocusTraversalPolicyMixin._requestFocus.Source§fn on_edge_for_direction(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
focused_child: AnyFocusNode,
group_node: Option<Handle<FocusTraversalGroupNode>>,
direction: TraversalDirection,
scope: Option<Handle<FocusScopeNode>>,
) -> bool
fn on_edge_for_direction( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, focused_child: AnyFocusNode, group_node: Option<Handle<FocusTraversalGroupNode>>, direction: TraversalDirection, scope: Option<Handle<FocusScopeNode>>, ) -> bool
Dart’s
DirectionalFocusTraversalPolicyMixin._onEdgeForDirection.Source§fn in_direction(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
direction: TraversalDirection,
) -> bool
fn in_direction( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, direction: TraversalDirection, ) -> bool
Focuses the next widget in the given
direction in the FocusScope that contains the
current_node. Read moreSource§impl FocusTraversalPolicy for ReadingOrderTraversalPolicy
impl FocusTraversalPolicy for ReadingOrderTraversalPolicy
Source§fn sort_descendants(
self: Handle<Self>,
app: &mut App,
descendants: Vec<AnyFocusNode>,
_current_node: AnyFocusNode,
) -> Vec<AnyFocusNode>
fn sort_descendants( self: Handle<Self>, app: &mut App, descendants: Vec<AnyFocusNode>, _current_node: AnyFocusNode, ) -> Vec<AnyFocusNode>
Sorts the list of nodes based on their geometry into the desired reading order based on the directionality of the context for each node.
Source§fn focus_traversal_policy_data(
self: Handle<Self>,
app: &App,
) -> &FocusTraversalPolicyData
fn focus_traversal_policy_data( self: Handle<Self>, app: &App, ) -> &FocusTraversalPolicyData
Dart’s
FocusTraversalPolicy fields, held under the field policy
(focus_traversal_policy_accessors!).Source§fn focus_traversal_policy_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut FocusTraversalPolicyData
fn focus_traversal_policy_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut FocusTraversalPolicyData
Source§fn invalidate_scope_data(
self: Handle<Self>,
app: &mut App,
node: Handle<FocusScopeNode>,
)
fn invalidate_scope_data( self: Handle<Self>, app: &mut App, node: Handle<FocusScopeNode>, )
Clears the data associated with the given
FocusScopeNode for this object. Read moreSource§fn changed_scope(
self: Handle<Self>,
app: &mut App,
node: Option<AnyFocusNode>,
old_scope: Option<Handle<FocusScopeNode>>,
)
fn changed_scope( self: Handle<Self>, app: &mut App, node: Option<AnyFocusNode>, old_scope: Option<Handle<FocusScopeNode>>, )
This is called whenever the given
node is re-parented into a new scope, so that the
policy has a chance to update or invalidate any cached data that it maintains per scope
about the node. Read moreSource§fn find_first_focus_in_direction(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
direction: TraversalDirection,
) -> Option<AnyFocusNode>
fn find_first_focus_in_direction( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, direction: TraversalDirection, ) -> Option<AnyFocusNode>
Returns the first node in the given
direction that should receive focus if there is no
current focus in the scope to which the current_node belongs. Read moreSource§fn in_direction(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
direction: TraversalDirection,
) -> bool
fn in_direction( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, direction: TraversalDirection, ) -> bool
Focuses the next widget in the given
direction in the focus scope that contains the
given current_node. Read moreSource§fn as_policy(self: Handle<Self>) -> AnyFocusTraversalPolicy
fn as_policy(self: Handle<Self>) -> AnyFocusTraversalPolicy
This policy as the erased
AnyFocusTraversalPolicy — what to pass where a Dart API
takes a FocusTraversalPolicy.Source§fn request_focus_callback(
self: Handle<Self>,
app: &App,
) -> TraversalRequestFocusCallback
fn request_focus_callback( self: Handle<Self>, app: &App, ) -> TraversalRequestFocusCallback
Source§fn set_request_focus_callback(
self: Handle<Self>,
app: &mut App,
value: TraversalRequestFocusCallback,
)
fn set_request_focus_callback( self: Handle<Self>, app: &mut App, value: TraversalRequestFocusCallback, )
Source§fn request_tab_traversal_focus(
self: Handle<Self>,
app: &mut App,
node: AnyFocusNode,
alignment_policy: Option<ScrollPositionAlignmentPolicy>,
alignment: Option<f64>,
duration: Option<Duration>,
curve: Option<Rc<dyn Curve>>,
forward: bool,
) -> bool
fn request_tab_traversal_focus( self: Handle<Self>, app: &mut App, node: AnyFocusNode, alignment_policy: Option<ScrollPositionAlignmentPolicy>, alignment: Option<f64>, duration: Option<Duration>, curve: Option<Rc<dyn Curve>>, forward: bool, ) -> bool
Request focus on a focus node as a result of a tab traversal. Read more
Source§fn find_first_focus(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
ignore_current_focus: bool,
) -> Option<AnyFocusNode>
fn find_first_focus( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, ignore_current_focus: bool, ) -> Option<AnyFocusNode>
Returns the node that should receive focus if focus is traversing forwards, and there is
no current focus. Read more
Source§fn find_last_focus(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
ignore_current_focus: bool,
) -> AnyFocusNode
fn find_last_focus( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, ignore_current_focus: bool, ) -> AnyFocusNode
Returns the node that should receive focus if focus is traversing backwards, and there
is no current focus.
Source§fn find_initial_focus(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
from_end: bool,
ignore_current_focus: bool,
) -> AnyFocusNode
fn find_initial_focus( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, from_end: bool, ignore_current_focus: bool, ) -> AnyFocusNode
Dart’s
FocusTraversalPolicy._findInitialFocus.Source§fn next(self: Handle<Self>, app: &mut App, current_node: AnyFocusNode) -> bool
fn next(self: Handle<Self>, app: &mut App, current_node: AnyFocusNode) -> bool
Focuses the next widget in the focus scope that contains the given
current_node. Read moreSource§fn previous(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
) -> bool
fn previous( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, ) -> bool
Focuses the previous widget in the focus scope that contains the given
current_node. Read moreSource§fn move_focus(
self: Handle<Self>,
app: &mut App,
current_node: AnyFocusNode,
forward: bool,
) -> bool
fn move_focus( self: Handle<Self>, app: &mut App, current_node: AnyFocusNode, forward: bool, ) -> bool
Moves the focus to the next node in the
FocusScopeNode nearest to the current_node
argument, either in a forward or reverse direction, depending on the value of the
forward argument. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ReadingOrderTraversalPolicy
impl !Send for ReadingOrderTraversalPolicy
impl !Sync for ReadingOrderTraversalPolicy
impl !UnwindSafe for ReadingOrderTraversalPolicy
impl Forget for ReadingOrderTraversalPolicy
impl Freeze for ReadingOrderTraversalPolicywhere
*const RcInner<dyn Fn(&mut App, AnyFocusNode, Option<ScrollPositionAlignmentPolicy>, Option<f64>, Option<Duration>, Option<Rc<dyn Curve>>)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode, Option<ScrollPositionAlignmentPolicy>, Option<f64>, Option<Duration>, Option<Rc<dyn Curve>>)>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(Retained<Handle<FocusScopeNode>>, DirectionalPolicyData)>: Freeze,
impl Move for ReadingOrderTraversalPolicy
impl Unpin for ReadingOrderTraversalPolicy
impl UnsafeUnpin for ReadingOrderTraversalPolicywhere
*const RcInner<dyn Fn(&mut App, AnyFocusNode, Option<ScrollPositionAlignmentPolicy>, Option<f64>, Option<Duration>, Option<Rc<dyn Curve>>)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyFocusNode, Option<ScrollPositionAlignmentPolicy>, Option<f64>, Option<Duration>, Option<Rc<dyn Curve>>)>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(Retained<Handle<FocusScopeNode>>, DirectionalPolicyData)>: 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
Mutably borrows from an owned value. Read more