pub struct ListState {
pub items: Vec<String>,
pub selected: usize,
pub filter: String,
/* private fields */
}Expand description
State for a selectable list widget.
Pass a mutable reference to Context::list each frame. Up/Down arrow
keys (and k/j) move the selection when the widget is focused.
Fields§
§items: Vec<String>The list items as display strings.
selected: usizeIndex of the currently selected item.
filter: StringCase-insensitive substring filter applied to list items.
Implementations§
Source§impl ListState
impl ListState
Sourcepub fn new(items: Vec<impl Into<String>>) -> Self
pub fn new(items: Vec<impl Into<String>>) -> Self
Create a list with the given items. The first item is selected initially.
Sourcepub fn set_filter(&mut self, filter: impl Into<String>)
pub fn set_filter(&mut self, filter: impl Into<String>)
Set the filter string. Multiple space-separated tokens are AND’d together — all tokens must match across any cell in the same row. Empty string disables filtering.
Sourcepub fn visible_indices(&self) -> &[usize]
pub fn visible_indices(&self) -> &[usize]
Returns indices of items visible after filtering.
Sourcepub fn selected_item(&self) -> Option<&str>
pub fn selected_item(&self) -> Option<&str>
Get the currently selected item text, or None if the list is empty.
Auto Trait Implementations§
impl Freeze for ListState
impl RefUnwindSafe for ListState
impl Send for ListState
impl Sync for ListState
impl Unpin for ListState
impl UnsafeUnpin for ListState
impl UnwindSafe for ListState
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