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

docs / components / navigation / context menu docs / components / navigation /

context menu

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

Commands for what is under the pointer, opened where it is.

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 context_menu --to ../my-app

Files copied: src/widgets/context_menu.rs, src/widgets/mod.rs

Usage

rust
use amenui::widgets::{context_menu};

fn view() -> El<Msg> {
    context_menu("cm1", None, &["打开", "重命名"], 0, Msg::Pick, Msg::Pick, Msg::Nothing)
}

API

Functionscontext_menu
Propskey, at (where it opens: logical px, None closed), items, active, pick, move_to, close.
Filessrc/widgets/context_menu.rs
Depends onbase
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

Statesclosed, open (a menu in a layer at at, an active item).
Keys and messagespick(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).