pub struct ChoiceState<T = usize>where
T: PartialEq,{
pub area: Rect,
pub nav_char: Vec<Vec<char>>,
pub keys: Vec<T>,
pub item_area: Rect,
pub button_area: Rect,
pub item_areas: Vec<Rect>,
pub selected: usize,
pub popup: PopupCoreState,
pub focus: FocusFlag,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
State.
Fields§
§area: RectTotal area. read only. renewed with each render.
First char of each item for navigation. read only. renewed with each render.
keys: Vec<T>Key for each item. read only. renewed with each render.
item_area: RectItem area in the main widget. read only. renewed with each render.
Button area in the main widget. read only. renewed with each render.
item_areas: Vec<Rect>Visible items in the popup. read only. renewed with each render.
selected: usizeSelect item. read+write
popup: PopupCoreStatePopup state.
focus: FocusFlagFocus flag. read+write
mouse: MouseFlagsMouse util.
non_exhaustive: NonExhaustiveImplementations§
Source§impl<T> ChoiceState<T>where
T: PartialEq,
impl<T> ChoiceState<T>where
T: PartialEq,
pub fn new() -> Self
pub fn named(name: &str) -> Self
Sourcepub fn is_popup_active(&self) -> bool
pub fn is_popup_active(&self) -> bool
Popup is active?
Sourcepub fn flip_popup_active(&mut self)
pub fn flip_popup_active(&mut self)
Flip the popup state.
Sourcepub fn set_popup_active(&mut self, active: bool) -> bool
pub fn set_popup_active(&mut self, active: bool) -> bool
Show the popup.
Sourcepub fn set_value(&mut self, key: &T) -> boolwhere
T: PartialEq,
pub fn set_value(&mut self, key: &T) -> boolwhere
T: PartialEq,
Select the given value.
Returns false if there is no such value, or no items, or nothing changed.
Doesn’t change the selection if the given key doesn’t exist.
Sourcepub fn try_value_ref(&self) -> Option<&T>
pub fn try_value_ref(&self) -> Option<&T>
Get the selected value or None if there are no items.
Sourcepub fn value_ref(&self) -> &T
pub fn value_ref(&self) -> &T
Get the selected value.
Panic
Panics if there is no selection or no items.
Sourcepub fn clear_offset(&mut self)
pub fn clear_offset(&mut self)
Scroll offset for the item list.
Sourcepub fn set_offset(&mut self, offset: usize) -> bool
pub fn set_offset(&mut self, offset: usize) -> bool
Scroll offset for the item list.
Sourcepub fn max_offset(&self) -> usize
pub fn max_offset(&self) -> usize
Scroll offset for the item list.
Sourcepub fn scroll_to_selected(&mut self) -> bool
pub fn scroll_to_selected(&mut self) -> bool
Scroll the item list to the selected value.
Source§impl<T> ChoiceState<T>
impl<T> ChoiceState<T>
Source§impl<T> ChoiceState<T>
impl<T> ChoiceState<T>
Sourcepub fn value_or_default(&self) -> T
pub fn value_or_default(&self) -> T
Get the selected value or T::default() if there are no items.
Source§impl<T> ChoiceState<T>where
T: PartialEq,
impl<T> ChoiceState<T>where
T: PartialEq,
Trait Implementations§
Source§impl<T> Clone for ChoiceState<T>
impl<T> Clone for ChoiceState<T>
Source§impl<T> Debug for ChoiceState<T>
impl<T> Debug for ChoiceState<T>
Source§impl<T> Default for ChoiceState<T>where
T: PartialEq,
impl<T> Default for ChoiceState<T>where
T: PartialEq,
Source§impl<T: PartialEq> HandleEvent<Event, MouseOnly, Outcome> for ChoiceState<T>
impl<T: PartialEq> HandleEvent<Event, MouseOnly, Outcome> for ChoiceState<T>
Source§impl<T: PartialEq> HandleEvent<Event, Popup, Outcome> for ChoiceState<T>
impl<T: PartialEq> HandleEvent<Event, Popup, Outcome> for ChoiceState<T>
Source§impl<T: PartialEq> HandleEvent<Event, Regular, Outcome> for ChoiceState<T>
impl<T: PartialEq> HandleEvent<Event, Regular, Outcome> for ChoiceState<T>
Source§impl<T> HasFocus for ChoiceState<T>where
T: PartialEq,
impl<T> HasFocus for ChoiceState<T>where
T: PartialEq,
Source§fn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Auto Trait Implementations§
impl<T = usize> !Freeze for ChoiceState<T>
impl<T = usize> !RefUnwindSafe for ChoiceState<T>
impl<T = usize> !Send for ChoiceState<T>
impl<T = usize> !Sync for ChoiceState<T>
impl<T> Unpin for ChoiceState<T>where
T: Unpin,
impl<T = usize> !UnwindSafe for ChoiceState<T>
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