pub struct ListState {
pub selected: Option<usize>,
pub offset: usize,
/* private fields */
}Expand description
Mutable state for a List widget tracking selection and scroll offset.
Fields§
§selected: Option<usize>Index of the currently selected item, if any.
offset: usizeScroll offset (first visible item index).
Implementations§
Source§impl ListState
impl ListState
Sourcepub fn select(&mut self, index: Option<usize>)
pub fn select(&mut self, index: Option<usize>)
Set the selected item index, or None to deselect.
Sourcepub fn with_persistence_id(self, id: impl Into<String>) -> Self
pub fn with_persistence_id(self, id: impl Into<String>) -> Self
Create a new ListState with a persistence ID for state saving.
Sourcepub fn persistence_id(&self) -> Option<&str>
pub fn persistence_id(&self) -> Option<&str>
Get the persistence ID, if set.
Trait Implementations§
Source§impl ListUndoExt for ListState
impl ListUndoExt for ListState
Source§fn selected_index(&self) -> Option<usize>
fn selected_index(&self) -> Option<usize>
Get the current selection.
Source§fn set_selected_index(&mut self, index: Option<usize>)
fn set_selected_index(&mut self, index: Option<usize>)
Set the selection.
Source§impl Stateful for ListState
impl Stateful for ListState
Source§type State = ListPersistState
type State = ListPersistState
The state type that gets persisted. Read more
Source§fn save_state(&self) -> ListPersistState
fn save_state(&self) -> ListPersistState
Extract current state for persistence. Read more
Source§fn restore_state(&mut self, state: ListPersistState)
fn restore_state(&mut self, state: ListPersistState)
Restore state from persistence. Read more
Source§fn state_version() -> u32
fn state_version() -> u32
State schema version for forward-compatible migrations. Read more
Source§impl UndoSupport for ListState
impl UndoSupport for ListState
Source§fn undo_widget_id(&self) -> UndoWidgetId
fn undo_widget_id(&self) -> UndoWidgetId
Get the widget’s unique ID for undo tracking.
Auto Trait Implementations§
impl Freeze for ListState
impl RefUnwindSafe for ListState
impl Send for ListState
impl Sync for ListState
impl Unpin 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