从按需打开的列表里选一项。
Enter、空格或 ↓ 打开,↑ ↓ 移动,Enter 选中,Esc 关上。
安装
组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:
cargo run --release --bin amenui -- add select --to ../my-app拷贝的文件: src/widgets/select.rs, src/widgets/mod.rs
用法
use amenui::widgets::{select};
fn view() -> El<Msg> {
select("se1", &["北京", "上海", "广州"], Some(0), false, 0, Msg::Nothing, Msg::Nothing, Msg::Pick, Msg::Pick)
}接口
| 函数 | select |
|---|---|
| 参数 | key, options, current, open, active (the option the keyboard is on while open), toggle, close, pick, move_to (the keyboard moves the active option). |
| 文件 | src/widgets/select.rs |
| 依赖 | base |
| 对波前的响应 | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| 重组 | keyed labels recompose when their text changes |
键盘与无障碍
| 状态 | closed (shows the choice), open (a listbox in a layer below), an active option. |
|---|---|
| 键盘与消息 | 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). |
在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。