pub struct SelectWidget {
pub open: bool,
/* private fields */
}Expand description
A scrollable pick-list widget with type-ahead filtering.
focused indexes the filtered set returned by Self::matches, not
options directly. When the filter matches nothing, value()/display()
return "" and next()/prev() are no-ops.
Fields§
§open: boolImplementations§
Source§impl SelectWidget
impl SelectWidget
pub fn new() -> Self
Sourcepub fn set_options(&mut self, options: Vec<SelectOption>)
pub fn set_options(&mut self, options: Vec<SelectOption>)
Replace the option list, reset focus to 0, and clear any query.
Sourcepub fn matches(&self) -> Vec<usize>
pub fn matches(&self) -> Vec<usize>
Indices into options whose label contains query case-insensitively.
An empty query returns all indices.
Sourcepub fn display(&self) -> &str
pub fn display(&self) -> &str
The display label of the focused filtered option, or "" when no match.
Sourcepub fn option_count(&self) -> usize
pub fn option_count(&self) -> usize
Number of options currently held (unfiltered).
Sourcepub fn options(&self) -> &[SelectOption]
pub fn options(&self) -> &[SelectOption]
The raw option list, for rendering.
Sourcepub fn focused_in_filtered(&self) -> usize
pub fn focused_in_filtered(&self) -> usize
Index of the focused entry within the filtered set (i.e. matches()).
Sourcepub fn filter_push(&mut self, c: char)
pub fn filter_push(&mut self, c: char)
Append a character to the type-ahead query and reset focus to 0.
Sourcepub fn filter_pop(&mut self)
pub fn filter_pop(&mut self)
Remove the last character from the type-ahead query and reset focus to 0.
Sourcepub fn confirm(&mut self)
pub fn confirm(&mut self)
Resolve the current filtered selection to the raw options index, clear the query, and close the dropdown. Call this on SelectConfirm so the selection survives query removal.
Sourcepub fn set_options_preserving_id(&mut self, options: Vec<SelectOption>)
pub fn set_options_preserving_id(&mut self, options: Vec<SelectOption>)
Replace the option list, keeping the previously selected id focused if it exists in the new list; falls back to index 0 otherwise. Clears query.
Trait Implementations§
Source§impl Clone for SelectWidget
impl Clone for SelectWidget
Source§fn clone(&self) -> SelectWidget
fn clone(&self) -> SelectWidget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SelectWidget
impl Debug for SelectWidget
Auto Trait Implementations§
impl Freeze for SelectWidget
impl RefUnwindSafe for SelectWidget
impl Send for SelectWidget
impl Sync for SelectWidget
impl Unpin for SelectWidget
impl UnsafeUnpin for SelectWidget
impl UnwindSafe for SelectWidget
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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