pub struct Selector { /* private fields */ }Expand description
A UI component use for navigating and selecting Option components.
It allows movement up and down between options and selection of an option.
§Usage
A Selector is required for Option components in a Container to work.
§Notes
- Without a
Selector,Optioncomponents in aContainercannot be selected or navigated.
Implementations§
Source§impl Selector
impl Selector
Sourcepub fn new(up_trig: Trigger, down_trig: Trigger, selc_trig: Trigger) -> Self
pub fn new(up_trig: Trigger, down_trig: Trigger, selc_trig: Trigger) -> Self
Constructs a new Selector component with triggers functions for
navigating up, down, and selecting. Each action is associated with a Trigger,
which determines whether the corresponding input (up, down, or select) is activated.
§Example
// A `Trigger` that always activates.
tui::trg_new_trigger_func!(always_true_trigger, _arg, {
Ok(true)
});
// A `Trigger` that never activates.
tui::trg_new_trigger_func!(always_false_trigger, _arg, {
Ok(false)
});
// Create a `Selector` that always moves down when evaluated.
let selector = Selector::new(
Trigger::no_arg(always_false_trigger), // up
Trigger::no_arg(always_true_trigger), // down
Trigger::no_arg(always_false_trigger), // select
);Sourcepub fn no_triggers() -> Self
pub fn no_triggers() -> Self
Creates a new Selector component without any trigger functions.
When using this variant, you must manually control its behavior by calling
the selector_up, selector_down, and selector_select methods on the
Container that contains it.
§Example
// Create a new `Selector` with no triggers.
let _ = Selector::no_triggers();
// Controlling the `Selector` manually.
// Build a container that contains a manual `Selector`.
let mut container = ContainerBuilder::new()
.selector_no_triggers()
.build();
// Move the selector up.
container.selector_up()?;
// Move the selector down.
container.selector_down()?;
// Select the currently highlighted option.
container.selector_select()?;pub fn up_trig_mut(&mut self) -> FtuiResult<&mut Trigger>
pub fn down_trig_mut(&mut self) -> FtuiResult<&mut Trigger>
pub fn select_trig_mut(&mut self) -> FtuiResult<&mut Trigger>
Sourcepub fn update_trig_arg<T, U, V>(
&mut self,
up_arg: T,
down_arg: U,
selc_arg: V,
) -> FtuiResult<()>where
T: 'static,
U: 'static,
V: 'static,
pub fn update_trig_arg<T, U, V>(
&mut self,
up_arg: T,
down_arg: U,
selc_arg: V,
) -> FtuiResult<()>where
T: 'static,
U: 'static,
V: 'static,
Update all of the Selector triggers argument.
Auto Trait Implementations§
impl !RefUnwindSafe for Selector
impl !Send for Selector
impl !Sync for Selector
impl !UnwindSafe for Selector
impl Freeze for Selector
impl Unpin for Selector
impl UnsafeUnpin for Selector
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