pub struct SelectState {
pub selected_index: Option<usize>,
pub is_open: bool,
pub focused: bool,
pub enabled: bool,
pub highlighted_index: usize,
pub scroll_offset: u16,
pub total_options: usize,
}Expand description
State for a select component.
Fields§
§selected_index: Option<usize>Currently selected index (None if nothing selected).
is_open: boolWhether the dropdown is open.
focused: boolWhether the select has focus.
enabled: boolWhether the select is enabled.
highlighted_index: usizeHighlighted index in dropdown (for keyboard navigation).
scroll_offset: u16Scroll offset for long option lists.
total_options: usizeTotal number of options.
Implementations§
Source§impl SelectState
impl SelectState
Sourcepub fn new(total_options: usize) -> Self
pub fn new(total_options: usize) -> Self
Create a new select state with given number of options.
Sourcepub fn with_selected(total_options: usize, selected: usize) -> Self
pub fn with_selected(total_options: usize, selected: usize) -> Self
Create with a pre-selected index.
Sourcepub fn highlight_prev(&mut self)
pub fn highlight_prev(&mut self)
Move highlight up.
Sourcepub fn highlight_next(&mut self)
pub fn highlight_next(&mut self)
Move highlight down.
Sourcepub fn highlight_first(&mut self)
pub fn highlight_first(&mut self)
Move highlight to first option.
Sourcepub fn highlight_last(&mut self)
pub fn highlight_last(&mut self)
Move highlight to last option.
Sourcepub fn select_highlighted(&mut self)
pub fn select_highlighted(&mut self)
Select the currently highlighted option and close.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
Sourcepub fn ensure_visible(&mut self, viewport_height: usize)
pub fn ensure_visible(&mut self, viewport_height: usize)
Ensure highlighted item is visible in viewport.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Check if an option is selected.
Trait Implementations§
Source§impl Clone for SelectState
impl Clone for SelectState
Source§fn clone(&self) -> SelectState
fn clone(&self) -> SelectState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SelectState
impl Debug for SelectState
Auto Trait Implementations§
impl Freeze for SelectState
impl RefUnwindSafe for SelectState
impl Send for SelectState
impl Sync for SelectState
impl Unpin for SelectState
impl UnwindSafe for SelectState
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
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>
Converts
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>
Converts
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