Commands for what is under the pointer, opened where it is.
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 context_menu --to ../my-appFiles copied: src/widgets/context_menu.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{context_menu};
fn view() -> El<Msg> {
context_menu("cm1", None, &["打开", "重命名"], 0, Msg::Pick, Msg::Pick, Msg::Nothing)
}API
| Functions | context_menu |
|---|---|
| Props | key, at (where it opens: logical px, None closed), items, active, pick, move_to, close. |
| Files | src/widgets/context_menu.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, open (a menu in a layer at at, an active item). |
|---|---|
| Keys and messages | pick(i) on an item or Enter; Up / Down / Home / End move_to(i); Esc or a press outside close (WAI-ARIA menu). |
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).