pub struct SelectList { /* private fields */ }Expand description
SelectList component.
Implementations§
Source§impl SelectList
impl SelectList
Sourcepub fn new(items: Vec<SelectItem>, max_visible: usize) -> Self
pub fn new(items: Vec<SelectItem>, max_visible: usize) -> Self
Create a new select list.
Sourcepub fn with_theme(
items: Vec<SelectItem>,
max_visible: usize,
theme: SelectListTheme,
) -> Self
pub fn with_theme( items: Vec<SelectItem>, max_visible: usize, theme: SelectListTheme, ) -> Self
Create a select list with a theme.
Sourcepub fn set_layout(&mut self, layout: SelectListLayoutOptions)
pub fn set_layout(&mut self, layout: SelectListLayoutOptions)
Override the primary/description column layout. The session picker uses this to widen the primary column so a preview is not clipped to the 32-column default.
Sourcepub fn new_multi(items: Vec<SelectItem>, max_visible: usize) -> Self
pub fn new_multi(items: Vec<SelectItem>, max_visible: usize) -> Self
Create a selector that permits selecting several options with Space
before submitting with Enter. Existing single-select selectors should
continue using Self::new.
Sourcepub fn is_multi_select(&self) -> bool
pub fn is_multi_select(&self) -> bool
Whether this list is in multi-select mode.
Sourcepub fn on_multi_select(
&self,
callback: Arc<dyn Fn(&[SelectItem]) + Send + Sync>,
)
pub fn on_multi_select( &self, callback: Arc<dyn Fn(&[SelectItem]) + Send + Sync>, )
Set a callback invoked with all toggled options when Enter is pressed.
Sourcepub fn get_selected_items(&self) -> Vec<SelectItem>
pub fn get_selected_items(&self) -> Vec<SelectItem>
Return the currently toggled options, preserving the source order.
Sourcepub fn toggle_selected(&self)
pub fn toggle_selected(&self)
Toggle the currently highlighted option. No-op for a regular selector.
Sourcepub fn set_filter(&self, filter: &str)
pub fn set_filter(&self, filter: &str)
Set the filter text.
Sourcepub fn set_selected_index(&self, index: usize)
pub fn set_selected_index(&self, index: usize)
Set the selected index.
Sourcepub fn get_selected_item(&self) -> Option<SelectItem>
pub fn get_selected_item(&self) -> Option<SelectItem>
Get the selected item.
Sourcepub fn on_select(&self, callback: Arc<dyn Fn(&SelectItem) + Send + Sync>)
pub fn on_select(&self, callback: Arc<dyn Fn(&SelectItem) + Send + Sync>)
Set callback for when an item is selected.
Sourcepub fn on_cancel(&self, callback: Arc<dyn Fn() + Send + Sync>)
pub fn on_cancel(&self, callback: Arc<dyn Fn() + Send + Sync>)
Set callback for when cancelled.
Sourcepub fn on_selection_change(
&self,
callback: Arc<dyn Fn(&SelectItem) + Send + Sync>,
)
pub fn on_selection_change( &self, callback: Arc<dyn Fn(&SelectItem) + Send + Sync>, )
Set callback for when selection changes.
Sourcepub fn handle_key(&self, key: KeyEvent)
pub fn handle_key(&self, key: KeyEvent)
Handle key input.