pub struct PickerState { /* private fields */ }Expand description
The internal state of the picker widget.
All sections are flattened into a single entries vec of headers and items.
Navigation moves the cursor between nav stops — visible items plus the
headers of collapsed sections — so a collapsed section can still be focused
and re-expanded. When nothing is collapsed, the nav stops are exactly the
items, matching a plain multi-select list.
Implementations§
Source§impl PickerState
impl PickerState
Sourcepub fn toggle(&mut self)
pub fn toggle(&mut self)
Toggle the checked state of the item under the cursor.
In a radio section, checking an item first unchecks every other item in the section; toggling an already-checked item unchecks it when it’s the only selection (so empty is reachable), but keeps it checked when multiple items were selected (resolving a pre-existing conflict by confirming the toggled choice). A no-op when the cursor is on a header.
Sourcepub fn toggle_current_section(&mut self)
pub fn toggle_current_section(&mut self)
Toggle all items in the section that contains the cursor.
In a checkbox section: if any item is unchecked, checks all; otherwise unchecks all. In a radio section this is a no-op — a radio section can never have every item selected.
Sourcepub fn clear_current_section(&mut self)
pub fn clear_current_section(&mut self)
Uncheck every item in the section that contains the cursor.
Bound to Backspace in radio sections to clear the current pick.
Sourcepub fn backspace(&mut self)
pub fn backspace(&mut self)
Backspace handler: clears the current section only when it is radio.
Sourcepub fn current_coordinates(&self) -> (usize, usize)
pub fn current_coordinates(&self) -> (usize, usize)
The (section_idx, item_idx) for the current cursor position.
When the cursor rests on a collapsed header, the item index is 0.
Sourcepub fn has_any_checked(&self) -> bool
pub fn has_any_checked(&self) -> bool
True if at least one item is checked across all sections.
Sourcepub fn collapse_current(&mut self)
pub fn collapse_current(&mut self)
Collapse the section that contains the cursor and focus its header, so the section can be re-expanded from that position.
Sourcepub fn expand_current(&mut self)
pub fn expand_current(&mut self)
Expand the section that contains the cursor and focus its first item (if any), restoring normal traversal through the section.
Sourcepub fn radio_conflict_title(&self) -> Option<&str>
pub fn radio_conflict_title(&self) -> Option<&str>
The title of the first radio section with more than one item checked, if any. Used to show a warning banner for a pre-existing conflicting state.
Sourcepub fn try_confirm(&mut self) -> Result<Vec<Vec<bool>>, String>
pub fn try_confirm(&mut self) -> Result<Vec<Vec<bool>>, String>
Validate radio constraints and, if satisfied, extract the results.
Returns Err naming the offending section when a radio section has more
than one item checked.
Sourcepub fn into_results(&mut self) -> Vec<Vec<bool>>
pub fn into_results(&mut self) -> Vec<Vec<bool>>
Extract checked state grouped by section (matching original input order).
Collapsed sections are included — collapse only hides items from the UI, never from the results.
Sourcepub fn scroll_offset(&self) -> usize
pub fn scroll_offset(&self) -> usize
Current scroll offset (for testing).
Sourcepub fn set_visible_height(&mut self, h: usize)
pub fn set_visible_height(&mut self, h: usize)
Set the visible height (normally set during render; exposed for testing).
Auto Trait Implementations§
impl Freeze for PickerState
impl RefUnwindSafe for PickerState
impl Send for PickerState
impl Sync for PickerState
impl Unpin for PickerState
impl UnsafeUnpin for PickerState
impl UnwindSafe for PickerState
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> 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