Struct zng::focus::WidgetFocusInfo
source · pub struct WidgetFocusInfo { /* private fields */ }
Expand description
WidgetInfo
wrapper that adds focus information for each widget.
Implementations§
source§impl WidgetFocusInfo
impl WidgetFocusInfo
sourcepub fn new(
widget_info: WidgetInfo,
focus_disabled_widgets: bool,
focus_hidden_widgets: bool,
) -> WidgetFocusInfo
pub fn new( widget_info: WidgetInfo, focus_disabled_widgets: bool, focus_hidden_widgets: bool, ) -> WidgetFocusInfo
Wrap a widget_info
reference to enable focus info querying.
See the FOCUS.focus_disabled_widgets
and FOCUS.focus_hidden_widgets
config for more details on the parameters.
sourcepub fn info(&self) -> &WidgetInfo
pub fn info(&self) -> &WidgetInfo
Full widget info.
sourcepub fn focus_disabled_widgets(&self) -> bool
pub fn focus_disabled_widgets(&self) -> bool
If DISABLED
widgets are focusable in this tree.
See the FOCUS.focus_disabled_widgets
config for more details.
If Hidden
widgets are focusable in this tree.
See the FOCUS.focus_hidden_widgets
config for more details.
sourcepub fn root(&self) -> WidgetFocusInfo
pub fn root(&self) -> WidgetFocusInfo
Root focusable.
sourcepub fn focus_tree(&self) -> FocusInfoTree
pub fn focus_tree(&self) -> FocusInfoTree
Clone a reference to the FocusInfoTree
that owns this widget.
sourcepub fn is_focusable(&self) -> bool
pub fn is_focusable(&self) -> bool
If the widget is focusable.
§Note
This is probably true
, the only way to get a WidgetFocusInfo
for a non-focusable widget is by
calling into_focus_info
or explicitly constructing one.
Focus scopes are also focusable.
sourcepub fn is_alt_scope(&self) -> bool
pub fn is_alt_scope(&self) -> bool
Is ALT focus scope.
sourcepub fn nested_window(&self) -> Option<WindowId>
pub fn nested_window(&self) -> Option<WindowId>
Gets the nested window ID, if this widget hosts a nested window.
Nested window hosts always focus the nested window on focus.
sourcepub fn nested_window_tree(&self) -> Option<FocusInfoTree>
pub fn nested_window_tree(&self) -> Option<FocusInfoTree>
Gets the nested window focus tree, if this widget hosts a nested window.
sourcepub fn focus_info(&self) -> FocusInfo
pub fn focus_info(&self) -> FocusInfo
Widget focus metadata.
sourcepub fn focus_info_ignore_blocked(&self) -> FocusInfo
pub fn focus_info_ignore_blocked(&self) -> FocusInfo
Widget focus metadata, all things equal except the widget interactivity is blocked.
sourcepub fn ancestors(&self) -> impl Iterator<Item = WidgetFocusInfo>
pub fn ancestors(&self) -> impl Iterator<Item = WidgetFocusInfo>
Iterator over focusable parent -> grandparent -> .. -> root.
sourcepub fn self_and_ancestors(&self) -> impl Iterator<Item = WidgetFocusInfo>
pub fn self_and_ancestors(&self) -> impl Iterator<Item = WidgetFocusInfo>
Iterator over self -> focusable parent -> grandparent -> .. -> root.
sourcepub fn scopes(&self) -> impl Iterator<Item = WidgetFocusInfo>
pub fn scopes(&self) -> impl Iterator<Item = WidgetFocusInfo>
Iterator over focus scopes parent -> grandparent -> .. -> root.
sourcepub fn parent(&self) -> Option<WidgetFocusInfo>
pub fn parent(&self) -> Option<WidgetFocusInfo>
Reference to the focusable parent that contains this widget.
sourcepub fn scope(&self) -> Option<WidgetFocusInfo>
pub fn scope(&self) -> Option<WidgetFocusInfo>
Reference the focus scope parent that contains the widget.
sourcepub fn alt_scope(&self) -> Option<WidgetFocusInfo>
pub fn alt_scope(&self) -> Option<WidgetFocusInfo>
Reference the ALT focus scope closest with the current widget.
§Closest Alt Scope
- If
self
is already an ALT scope or is in one, moves to a sibling ALT scope, nested ALT scopes are ignored. - If
self
is a normal scope, moves to the first descendant ALT scope, otherwise.. - Recursively searches for an ALT scope sibling up the scope tree.
sourcepub fn in_alt_scope(&self) -> bool
pub fn in_alt_scope(&self) -> bool
Widget is in a ALT scope or is an ALT scope.
sourcepub fn on_focus_scope_move<'f>(
&self,
last_focused: impl FnOnce(WidgetId) -> Option<&'f WidgetPath>,
is_tab_cycle_reentry: bool,
reverse: bool,
) -> Option<WidgetFocusInfo>
pub fn on_focus_scope_move<'f>( &self, last_focused: impl FnOnce(WidgetId) -> Option<&'f WidgetPath>, is_tab_cycle_reentry: bool, reverse: bool, ) -> Option<WidgetFocusInfo>
Widget the focus needs to move to when self
gets focused.
§Input
last_focused
: A function that returns the last focused widget within a focus scope identified byWidgetId
.is_tab_cycle_reentry
: If the focus returned toself
immediately after leaving because the parent scope isTabNav::Cycle
.reverse
: If the focus reversed intoself
.
§Returns
Returns the different widget the focus must move to after focusing in self
that is a focus scope.
If self
is not a FocusScope
always returns None
.
sourcepub fn descendants(&self) -> FocusTreeIter<TreeIter> ⓘ
pub fn descendants(&self) -> FocusTreeIter<TreeIter> ⓘ
Iterator over the focusable widgets contained by this widget.
sourcepub fn self_and_descendants(&self) -> FocusTreeIter<TreeIter> ⓘ
pub fn self_and_descendants(&self) -> FocusTreeIter<TreeIter> ⓘ
Iterator over self and the focusable widgets contained by it.
sourcepub fn has_tab_descendant(&self) -> bool
pub fn has_tab_descendant(&self) -> bool
If the focusable has any focusable descendant that is not TabIndex::SKIP
sourcepub fn first_tab_descendant(&self) -> Option<WidgetFocusInfo>
pub fn first_tab_descendant(&self) -> Option<WidgetFocusInfo>
First descendant considering TAB index.
sourcepub fn last_tab_descendant(&self) -> Option<WidgetFocusInfo>
pub fn last_tab_descendant(&self) -> Option<WidgetFocusInfo>
Last descendant considering TAB index.
sourcepub fn next_focusables(&self) -> FocusTreeIter<TreeIter> ⓘ
pub fn next_focusables(&self) -> FocusTreeIter<TreeIter> ⓘ
Iterator over all focusable widgets in the same scope after this widget.
sourcepub fn next_focusable(&self) -> Option<WidgetFocusInfo>
pub fn next_focusable(&self) -> Option<WidgetFocusInfo>
Next focusable in the same scope after this widget.
sourcepub fn next_tab_focusable(&self, skip_self: bool) -> Option<WidgetFocusInfo>
pub fn next_tab_focusable(&self, skip_self: bool) -> Option<WidgetFocusInfo>
Next focusable in the same scope after this widget respecting the TAB index.
If self
is set to TabIndex::SKIP
returns the next non-skip focusable in the same scope after this widget.
If skip_self
is true
, does not include widgets inside self
.
sourcepub fn prev_focusables(&self) -> FocusTreeIter<RevTreeIter> ⓘ
pub fn prev_focusables(&self) -> FocusTreeIter<RevTreeIter> ⓘ
Iterator over all focusable widgets in the same scope before this widget in reverse.
sourcepub fn prev_focusable(&self) -> Option<WidgetFocusInfo>
pub fn prev_focusable(&self) -> Option<WidgetFocusInfo>
Previous focusable in the same scope before this widget.
sourcepub fn prev_tab_focusable(&self, skip_self: bool) -> Option<WidgetFocusInfo>
pub fn prev_tab_focusable(&self, skip_self: bool) -> Option<WidgetFocusInfo>
Previous focusable in the same scope after this widget respecting the TAB index.
If self
is set to TabIndex::SKIP
returns the previous non-skip focusable in the same scope before this widget.
If skip_self
is true
, does not include widgets inside self
.
sourcepub fn next_tab(&self, skip_self: bool) -> Option<WidgetFocusInfo>
pub fn next_tab(&self, skip_self: bool) -> Option<WidgetFocusInfo>
Widget to focus when pressing TAB from this widget.
Set skip_self
to not enter self
, that is, the focus goes to the next sibling or next sibling descendant.
Returns None
if the focus does not move to another widget.
sourcepub fn prev_tab(&self, skip_self: bool) -> Option<WidgetFocusInfo>
pub fn prev_tab(&self, skip_self: bool) -> Option<WidgetFocusInfo>
Widget to focus when pressing SHIFT+TAB from this widget.
Set skip_self
to not enter self
, that is, the focus goes to the previous sibling or previous sibling descendant.
Returns None
if the focus does not move to another widget.
sourcepub fn nearest(
&self,
origin: Point2D<Px, Px>,
max_radius: Px,
) -> Option<WidgetFocusInfo>
pub fn nearest( &self, origin: Point2D<Px, Px>, max_radius: Px, ) -> Option<WidgetFocusInfo>
Find the focusable descendant with center point nearest of origin
within the max_radius
.
sourcepub fn nearest_filtered(
&self,
origin: Point2D<Px, Px>,
max_radius: Px,
filter: impl FnMut(WidgetFocusInfo) -> bool,
) -> Option<WidgetFocusInfo>
pub fn nearest_filtered( &self, origin: Point2D<Px, Px>, max_radius: Px, filter: impl FnMut(WidgetFocusInfo) -> bool, ) -> Option<WidgetFocusInfo>
Find the descendant with center point nearest of origin
within the max_radius
and approved by the filter
closure.
sourcepub fn nearest_bounded_filtered(
&self,
origin: Point2D<Px, Px>,
max_radius: Px,
bounds: Rect<Px, Px>,
filter: impl FnMut(WidgetFocusInfo) -> bool,
) -> Option<WidgetFocusInfo>
pub fn nearest_bounded_filtered( &self, origin: Point2D<Px, Px>, max_radius: Px, bounds: Rect<Px, Px>, filter: impl FnMut(WidgetFocusInfo) -> bool, ) -> Option<WidgetFocusInfo>
Find the descendant with center point nearest of origin
within the max_radius
and inside bounds
; and approved by the filter
closure.
sourcepub fn nearest_oriented(
&self,
origin: Point2D<Px, Px>,
max_distance: Px,
orientation: Orientation2D,
) -> Option<WidgetFocusInfo>
pub fn nearest_oriented( &self, origin: Point2D<Px, Px>, max_distance: Px, orientation: Orientation2D, ) -> Option<WidgetFocusInfo>
Find the focusable descendant with center point nearest of origin
within the max_distance
and with orientation
to origin.
sourcepub fn nearest_oriented_filtered(
&self,
origin: Point2D<Px, Px>,
max_distance: Px,
orientation: Orientation2D,
filter: impl FnMut(WidgetFocusInfo) -> bool,
) -> Option<WidgetFocusInfo>
pub fn nearest_oriented_filtered( &self, origin: Point2D<Px, Px>, max_distance: Px, orientation: Orientation2D, filter: impl FnMut(WidgetFocusInfo) -> bool, ) -> Option<WidgetFocusInfo>
Find the focusable descendant with center point nearest of origin
within the max_distance
and with orientation
to origin that passes the filter
.
sourcepub fn focusable_up(&self) -> Option<WidgetFocusInfo>
pub fn focusable_up(&self) -> Option<WidgetFocusInfo>
Closest focusable in the same scope above this widget.
sourcepub fn focusable_down(&self) -> Option<WidgetFocusInfo>
pub fn focusable_down(&self) -> Option<WidgetFocusInfo>
Closest focusable in the same scope below this widget.
sourcepub fn focusable_left(&self) -> Option<WidgetFocusInfo>
pub fn focusable_left(&self) -> Option<WidgetFocusInfo>
Closest focusable in the same scope to the left of this widget.
sourcepub fn focusable_right(&self) -> Option<WidgetFocusInfo>
pub fn focusable_right(&self) -> Option<WidgetFocusInfo>
Closest focusable in the same scope to the right of this widget.
sourcepub fn next_up(&self) -> Option<WidgetFocusInfo>
pub fn next_up(&self) -> Option<WidgetFocusInfo>
Widget to focus when pressing the arrow up key from this widget.
sourcepub fn next_right(&self) -> Option<WidgetFocusInfo>
pub fn next_right(&self) -> Option<WidgetFocusInfo>
Widget to focus when pressing the arrow right key from this widget.
sourcepub fn next_down(&self) -> Option<WidgetFocusInfo>
pub fn next_down(&self) -> Option<WidgetFocusInfo>
Widget to focus when pressing the arrow down key from this widget.
sourcepub fn next_left(&self) -> Option<WidgetFocusInfo>
pub fn next_left(&self) -> Option<WidgetFocusInfo>
Widget to focus when pressing the arrow left key from this widget.
Focus navigation actions that can move the focus away from this item.
Trait Implementations§
source§impl Clone for WidgetFocusInfo
impl Clone for WidgetFocusInfo
source§fn clone(&self) -> WidgetFocusInfo
fn clone(&self) -> WidgetFocusInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WidgetFocusInfo
impl Debug for WidgetFocusInfo
source§impl Hash for WidgetFocusInfo
impl Hash for WidgetFocusInfo
source§impl PartialEq for WidgetFocusInfo
impl PartialEq for WidgetFocusInfo
impl Eq for WidgetFocusInfo
impl StructuralPartialEq for WidgetFocusInfo
Auto Trait Implementations§
impl Freeze for WidgetFocusInfo
impl !RefUnwindSafe for WidgetFocusInfo
impl Send for WidgetFocusInfo
impl Sync for WidgetFocusInfo
impl Unpin for WidgetFocusInfo
impl !UnwindSafe for WidgetFocusInfo
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more