打字找到并执行一个命令(⌘K / Ctrl+K)。
安装
组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:
cargo run --release --bin amenui -- add command --to ../my-app拷贝的文件: src/widgets/command.rs, src/widgets/mod.rs, src/widgets/input.rs
用法
use amenui::widgets::{command, command_matches};
fn view() -> El<Msg> {
command("cp1", &TextEdit::new("sa"), &["open file", "save all", "close window"], 0, Msg::Edit, Msg::Pick)
}接口
| 函数 | command, command_matches |
|---|---|
| 参数 | key, query (a TextEdit), items (labels), active, on_query, run. |
| 文件 | src/widgets/command.rs |
| 依赖 | base, input |
| 对波前的响应 | 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 |
键盘与无障碍
| 状态 | the query; the matching items (every typed character in order); one active. |
|---|---|
| 键盘与消息 | on_query(edit) while typing; Up / Down move active (through on_query of the same text with the arrow's step, see command_step); Enter run(i) (the item's index in items). |
在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。