amenui
en·中 github ↗ v0.0.1
01docs 02components 03lab 04works
en·中github ↗
×

docs / components / navigation / command docs / components / navigation /

command

04.31
On this page ▾
  1. Installation
  2. Usage
  3. API
  4. Keyboard and accessibility

Find and run a command by typing.

drawn by amenuiopen ↗

Installation

Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:

sh
cargo run --release --bin amenui -- add command --to ../my-app

Files copied: src/widgets/command.rs, src/widgets/mod.rs, src/widgets/input.rs

Usage

rust
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)
}

API

Functionscommand, command_matches
Propskey, query (a TextEdit), items (labels), active, on_query, run.
Filessrc/widgets/command.rs
Depends onbase, input
Response to frontsnudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap)
Recompositionkeyed labels recompose when their text changes

Keyboard and accessibility

Statesthe query; the matching items (every typed character in order); one active.
Keys and messageson_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).

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).