Skip to main content

ReadingOrderTraversalPolicy

Struct ReadingOrderTraversalPolicy 

Source
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:

  1. Find the node rectangle that has the highest top on the screen.
  2. Find any other nodes that intersect the infinite horizontal band defined by the highest rectangle’s top and bottom edges.
  3. 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

Source

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.

Source

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

Source§

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

Source§

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

Dart’s DirectionalFocusTraversalPolicyMixin.changedScope.
Source§

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>

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

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

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

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

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

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

Dart’s DirectionalFocusTraversalPolicyMixin._onEdgeForDirection.
Source§

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 more
Source§

impl FocusTraversalPolicy for ReadingOrderTraversalPolicy

Source§

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

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

Source§

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 more
Source§

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 more
Source§

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 more
Source§

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 more
Source§

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

Source§

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

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>

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

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

Dart’s FocusTraversalPolicy._findInitialFocus.
Source§

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 more
Source§

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 more
Source§

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 more

Auto 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 ReadingOrderTraversalPolicy

§

impl Move for ReadingOrderTraversalPolicy

§

impl Unpin for ReadingOrderTraversalPolicy
where Rc<dyn Fn(&mut App, AnyFocusNode, Option<ScrollPositionAlignmentPolicy>, Option<f64>, Option<Duration>, Option<Rc<dyn Curve>>)>: Unpin, *const u8 is !null: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, &'static FocusNodeVTable: Unpin,

§

impl UnsafeUnpin for ReadingOrderTraversalPolicy

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