pub struct Dropdown {
pub style: Style,
pub item_style: Style,
pub selected_color: Color,
pub text_color: Color,
/* private fields */
}Expand description
Closed-trigger + open-list selector widget (LPAR-13 §5.C).
Stores option strings as owned Strings so callers are not required to
keep the source slice alive.
Fields§
§style: StyleBackground + border style for the trigger button (Part::MAIN).
item_style: StyleStyle applied to option rows (Part::ITEMS).
selected_color: ColorHighlight color for the selected row (Part::SELECTED).
text_color: ColorText color for option labels.
Implementations§
Source§impl Dropdown
impl Dropdown
Sourcepub fn new(bounds: Rect) -> Self
pub fn new(bounds: Rect) -> Self
Create a Dropdown occupying bounds with no options and the first
option selected.
Sourcepub fn set_font(&mut self, font: &'static dyn FontMetrics)
pub fn set_font(&mut self, font: &'static dyn FontMetrics)
Assign the font used to render this widget (FONT-00 §5); resolves to
FONT_6X10 when unset.
Sourcepub fn set_options(&mut self, options: &[impl AsRef<str>])
pub fn set_options(&mut self, options: &[impl AsRef<str>])
Replace the option list.
selected is reset to 0 regardless of the previous value.
Sourcepub fn option_count(&self) -> usize
pub fn option_count(&self) -> usize
Return the number of options.
Sourcepub fn set_selected(&mut self, index: usize)
pub fn set_selected(&mut self, index: usize)
Set the selected index (clamped to 0..options.len()).
Sourcepub fn selected_text(&self) -> &str
pub fn selected_text(&self) -> &str
Return the text of the selected option, or "" when the list is empty.
Sourcepub fn set_dir(&mut self, dir: DropdownDir)
pub fn set_dir(&mut self, dir: DropdownDir)
Set the direction the open list grows relative to the trigger.
Sourcepub fn dir(&self) -> DropdownDir
pub fn dir(&self) -> DropdownDir
Return the current open direction.
Sourcepub fn set_symbol(&mut self, sym: Option<&str>)
pub fn set_symbol(&mut self, sym: Option<&str>)
Set an optional indicator glyph drawn at the right of the trigger.
Sourcepub fn set_selected_highlight(&mut self, enable: bool)
pub fn set_selected_highlight(&mut self, enable: bool)
Set whether the selected option is highlighted inside the open list.
Sourcepub fn selected_highlight(&self) -> bool
pub fn selected_highlight(&self) -> bool
Return whether selected-item highlighting is enabled.
Move the highlighted selection one step downward, wrapping at the end.
Wire to ObjectEvent::Key(Key::ArrowDown) via a node handler.
Move the highlighted selection one step upward, wrapping at the start.
Wire to ObjectEvent::Key(Key::ArrowUp) via a node handler.
Sourcepub fn activate_selected(&mut self)
pub fn activate_selected(&mut self)
Confirm the current highlighted selection and close the list.
Wire to ObjectEvent::Key(Key::Enter) via a node handler.