pub struct Focus<'a> {
pub core: FocusCore<'a>,
/* private fields */
}Fields§
§core: FocusCore<'a>Implementations§
source§impl<'a> Focus<'a>
impl<'a> Focus<'a>
sourcepub fn new(list: &[&'a dyn HasFocusFlag]) -> Self
pub fn new(list: &[&'a dyn HasFocusFlag]) -> Self
Construct a new focus list.
sourcepub fn new_container(
c: &'a dyn HasFocusFlag,
list: &[&'a dyn HasFocusFlag],
) -> Self
pub fn new_container( c: &'a dyn HasFocusFlag, list: &[&'a dyn HasFocusFlag], ) -> Self
Construct a new focus list for a container widget.
The focus-flag for the container accumulates all the flags. If any has focus, the container has the focus too. Focus-gained and focus-lost are only set if the focus leaves the container.
The container widget itself interacts with the mouse too. If no single widget is hit with the mouse, but the area of the container is, the first widget gets the focus.
See examples/focus_recursive and examples/focus_recursive2
sourcepub fn new_grp(grp: &'a FocusFlag, list: &[&'a dyn HasFocusFlag]) -> Self
pub fn new_grp(grp: &'a FocusFlag, list: &[&'a dyn HasFocusFlag]) -> Self
Construct a new focus list with group accumulator.
This is meant for some loose grouping of widgets, for which you want an overview.
The same rules apply as for new_accu(), but with this one there is no overall area for mouse interaction.
sourcepub fn add_flag(&mut self, flag: &'a FocusFlag, area: Rect) -> &mut Self
pub fn add_flag(&mut self, flag: &'a FocusFlag, area: Rect) -> &mut Self
Add a single widget. This doesn’t add any z_areas and assumes navigable is true.
sourcepub fn add_focus(&mut self, focus: Focus<'a>) -> &mut Self
pub fn add_focus(&mut self, focus: Focus<'a>) -> &mut Self
Add a sub-focus cycle.
All its widgets are appended to this list. If the sub-cycle has an accumulator it’s added to the sub-accumulators. All sub-sub-accumulators are appended too.
sourcepub fn add_container(&mut self, c: &'a dyn HasFocus) -> &mut Self
pub fn add_container(&mut self, c: &'a dyn HasFocus) -> &mut Self
Add a container widget.
sourcepub fn add(&mut self, f: &'a dyn HasFocusFlag) -> &mut Self
pub fn add(&mut self, f: &'a dyn HasFocusFlag) -> &mut Self
Add a single widget.
sourcepub fn add_all(&mut self, list: &[&'a dyn HasFocusFlag]) -> &mut Self
pub fn add_all(&mut self, list: &[&'a dyn HasFocusFlag]) -> &mut Self
Add a list of widgets.
sourcepub fn enable_log(&self, log: bool)
pub fn enable_log(&self, log: bool)
Writes a log for each operation.
sourcepub fn init(&self)
pub fn init(&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 focus_widget_no_lost(&self, widget_state: &'a dyn HasFocusFlag)
pub fn focus_widget_no_lost(&self, widget_state: &'a dyn HasFocusFlag)
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_widget(&self, widget_state: &'a dyn HasFocusFlag)
pub fn focus_widget(&self, widget_state: &'a dyn HasFocusFlag)
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 focus_no_lost(&self, flag: &FocusFlag)
pub fn focus_no_lost(&self, flag: &FocusFlag)
Sets the focus to the widget.
Sets focus and gained but not lost. This can be used to prevent validation of the field.
sourcepub fn focus(&self, flag: &FocusFlag)
pub fn focus(&self, flag: &FocusFlag)
Sets the focus to the widget with tag.
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 focused(&self) -> Option<&'a FocusFlag>
pub fn focused(&self) -> Option<&'a 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 lost_focus(&self) -> Option<&'a FocusFlag>
pub fn lost_focus(&self) -> Option<&'a 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<&'a FocusFlag>
pub fn gained_focus(&self) -> Option<&'a 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 focus_idx(&self, idx: usize)
pub fn focus_idx(&self, idx: usize)
Change the focus.
Sets the focus, gained and lost flags. If this ends up with the same widget as before gained and lost flags are not set.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for Focus<'a>
impl<'a> !RefUnwindSafe for Focus<'a>
impl<'a> !Send for Focus<'a>
impl<'a> !Sync for Focus<'a>
impl<'a> Unpin for Focus<'a>
impl<'a> !UnwindSafe for Focus<'a>
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> 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