Choose one option from a list that opens on demand.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add select --to ../my-appFiles copied: src/widgets/select.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{select};
fn view() -> El<Msg> {
select("se1", &["北京", "上海", "广州"], Some(0), false, 0, Msg::Nothing, Msg::Nothing, Msg::Pick, Msg::Pick)
}API
| Functions | select |
|---|---|
| Props | key, options, current, open, active (the option the keyboard is on while open), toggle, close, pick, move_to (the keyboard moves the active option). |
| Files | src/widgets/select.rs |
| Depends on | base |
| Response to fronts | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| Recomposition | keyed labels recompose when their text changes |
Keyboard and accessibility
| States | closed (shows the choice), open (a listbox in a layer below), an active option. |
|---|---|
| Keys and messages | toggle on press, Enter, Space or Down (closed); while open Up / Down / Home / End send move_to(i), Enter / Space pick(active), Esc or a press outside close (WAI-ARIA select-only combobox). |
On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).