pub struct SettingsList { /* private fields */ }Expand description
A scrollable list of toggleable settings rendered as checkboxes.
Each item is a (name, value) pair where value is true for checked
[x] and false for unchecked [ ]. Items can be toggled with Enter
or Space, and an optional on_change callback is fired on every toggle.
Implementations§
Source§impl SettingsList
impl SettingsList
Sourcepub fn new(items: Vec<(String, bool)>) -> Self
pub fn new(items: Vec<(String, bool)>) -> Self
Create a new settings list from (name, value) pairs.
Sourcepub fn on_change(self, cb: fn(usize, bool)) -> Self
pub fn on_change(self, cb: fn(usize, bool)) -> Self
Attach a callback invoked when an item is toggled.
The callback receives (index, new_value).
Sourcepub fn set_selected(&mut self, index: usize)
pub fn set_selected(&mut self, index: usize)
Set the selected item index (clamped to valid range).
Trait Implementations§
Source§impl Component for SettingsList
impl Component for SettingsList
Source§fn render(&self, width: u16) -> Result<Rendered, RenderError>
fn render(&self, width: u16) -> Result<Rendered, RenderError>
Render this component into lines of text at the given width. Read more
Source§fn handle_input(&mut self, event: &Event) -> InputResult
fn handle_input(&mut self, event: &Event) -> InputResult
Handle an input event (key press, resize, mouse, etc.). Read more
Source§fn as_focusable(&self) -> Option<&dyn Focusable>
fn as_focusable(&self) -> Option<&dyn Focusable>
Cast this component to a
Focusable reference, if supported.Source§fn as_focusable_mut(&mut self) -> Option<&mut dyn Focusable>
fn as_focusable_mut(&mut self) -> Option<&mut dyn Focusable>
Cast this component to a mutable
Focusable reference, if supported.Source§fn render_rect(&self, rect: Rect) -> Result<Rendered, RenderError>
fn render_rect(&self, rect: Rect) -> Result<Rendered, RenderError>
Render this component into a specific rectangular area. Read more
Source§fn wants_key_release(&self) -> bool
fn wants_key_release(&self) -> bool
Returns
true if this component wants to receive
KeyEventKind::Release events in addition to Press / Repeat. Read moreAuto Trait Implementations§
impl Freeze for SettingsList
impl RefUnwindSafe for SettingsList
impl Send for SettingsList
impl Sync for SettingsList
impl Unpin for SettingsList
impl UnsafeUnpin for SettingsList
impl UnwindSafe for SettingsList
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