pub struct Focus { /* private fields */ }Expand description
Focus deals with all focus-related issues.
It must be constructed at least after each render(), as it holds copies of the widget-areas for mouse-handling.
In practice, construct it, when you first need it.
Implementations§
Source§impl Focus
impl Focus
Sourcepub fn remove_container(&mut self, container: &dyn HasFocus)
pub fn remove_container(&mut self, container: &dyn HasFocus)
Dynamic change of the widget structure of a container widget.
This is only necessary if your widget structure changes during event-handling, and you need a programmatic focus-change for the new structure.
This resets the focus-flags of the removed container.
Sourcepub fn update_container(&mut self, container: &dyn HasFocus)
pub fn update_container(&mut self, container: &dyn HasFocus)
Dynamic change of the widget structure of a container.
This is only necessary if your widget structure changes during event-handling, and you need a programmatic focus-change for the new structure.
If the widget that currently has the focus is still part of the widget structure it keeps the focus. The focus-flags for all widgets that are no longer part of the widget structure are reset.
Sourcepub fn replace_container(
&mut self,
container: &dyn HasFocus,
new: &dyn HasFocus,
)
pub fn replace_container( &mut self, container: &dyn HasFocus, new: &dyn HasFocus, )
Dynamic change of the widget structure of a container.
This is only necessary if your widget structure changes during event-handling, and you need a programmatic focus-change.
This removes the widgets of one container and inserts the widgets of the other one in place.
If the widget that currently has the focus is still part of the widget structure it keeps the focus. The focus-flags for all widgets that are no longer part of the widget structure are reset.
Sourcepub fn enable_log(&self)
pub fn enable_log(&self)
Writes a log for each operation.
Sourcepub fn disable_log(&self)
pub fn disable_log(&self)
Writes a log for each operation.
Sourcepub fn focus_no_lost(&self, widget_state: &dyn HasFocus)
pub fn focus_no_lost(&self, widget_state: &dyn HasFocus)
Sets the focus to the widget.
Sets the focus, but doesn’t set lost or gained. This can be used to prevent validation of the field.
Sourcepub fn focus(&self, widget_state: &dyn HasFocus)
pub fn focus(&self, widget_state: &dyn HasFocus)
Sets the focus to the given widget.
Sets the focus, gained and lost flags.
If this ends up with the same widget as before gained and lost flags are not set.
Sourcepub fn expel_focus(&self, widget_state: &dyn HasFocus)
pub fn expel_focus(&self, widget_state: &dyn HasFocus)
Expels the focus from the given widget regardless of the current state.
Sourcepub fn focused(&self) -> Option<FocusFlag>
pub fn focused(&self) -> Option<FocusFlag>
Returns the focused widget as FocusFlag.
This is mainly for debugging purposes. For control-flow crate::match_focus or crate::on_gained or crate::on_lost will be nicer.
Sourcepub fn focused_name(&self) -> Option<String>
pub fn focused_name(&self) -> Option<String>
Returns the debug name of the focused widget.
This is mainly for debugging purposes.
Returns the navigation flag for the focused widget.
Sourcepub fn lost_focus(&self) -> Option<FocusFlag>
pub fn lost_focus(&self) -> Option<FocusFlag>
Returns the widget that lost the focus as FocusFlag.
This is mainly for debugging purposes. For control-flow crate::match_focus or crate::on_gained or crate::on_lost will be nicer.
Sourcepub fn gained_focus(&self) -> Option<FocusFlag>
pub fn gained_focus(&self) -> Option<FocusFlag>
Returns the widget that gained the focus as FocusFlag.
This is mainly for debugging purposes. For control-flow crate::match_focus or crate::on_gained or crate::on_lost will be nicer.
Sourcepub fn reset_lost_gained(&self)
pub fn reset_lost_gained(&self)
Reset lost + gained flags.
This is done automatically in HandleEvent::handle() for every event.
Sourcepub fn first(&self)
pub fn first(&self)
Set the initial state for all widgets.
This ensures that there is only one focused widget. The first widget in the list gets the focus.
Sourcepub fn first_in(&self, container: &dyn HasFocus)
pub fn first_in(&self, container: &dyn HasFocus)
Focus the first widget of a given container. It the given HasFocus is a widget it will get the focus.
The first navigable widget in the container gets the focus.
Sourcepub fn none(&self)
pub fn none(&self)
Clear the focus for all widgets.
When navigating after this focus will restart somewhere, most probably the very first widget.
Sourcepub fn next(&self) -> bool
pub fn next(&self) -> bool
Focus the next widget in the cycle.
Sets the focus, gained and lost flags. If this ends up with the same widget as before focus, gained and lost flag are all set.
If no field has the focus the first one gets it.
Sourcepub fn prev(&self) -> bool
pub fn prev(&self) -> bool
Focus the previous widget in the cycle.
Sets the focus and lost flags. If this ends up with the same widget as before it returns true and sets the focus, gained and lost flag.
If no field has the focus the first one gets it.
Sourcepub fn next_force(&self) -> bool
pub fn next_force(&self) -> bool
Focus the next widget in the cycle. Applies some extra force to this action and allows leaving widgets that have Navigation::(Mouse, ReachLeafFront, Reach).
Sets the focus, gained and lost flags. If this ends up with the same widget as before focus, gained and lost flag are all set.
If no field has the focus the first one gets it.
Sourcepub fn prev_force(&self) -> bool
pub fn prev_force(&self) -> bool
Focus the previous widget in the cycle.
Applies some extra force to this action and allows leaving widgets that have Navigation::(Mouse, ReachLeafBack, Reach).
Sets the focus and lost flags. If this ends up with the same widget as before it returns true and sets the focus, gained and lost flag.
If no field has the focus the first one gets it.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Focus
impl !RefUnwindSafe for Focus
impl !Send for Focus
impl !Sync for Focus
impl Unpin for Focus
impl !UnwindSafe for Focus
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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