# Menu
`deft/stdext/menu` is a type-only module: it defines the shared
`%MenuItem` type used by every app menu bar. There are no functions.
import "deft/stdext/menu" as menu
Once imported, the type registers runtime-wide and is constructed
unqualified.
## Type
| Type | Fields |
|---|---|
| `MenuItem` | `label :string`, `action :string`, `shortcut :string` |
- `:action` names a function evaluated in the app's runtime when the
item is selected.
- `:shortcut` is a display string only — the key is still bound in the
app's key handler. The editor derives it automatically: at menu
build time each item resolves the chord bound to its action's command
(registry + user keytable overrides + driver delta + extension and
mode keymaps), so editor extension menus should leave it `""`. Other
apps set it by hand.
## Usage
def get-menu {|| %{ "Edit" @{ %MenuItem{ label "Delete" action "delete-selected" shortcut "Ctrl+D" } } } }
`tui/set-menu` accepts either the plain map form above or an ordered
form:
%{ "File" %{ :order 1 :items @{ %MenuItem{ … } } } }
`tui/menu-update` re-evaluates the app's zero-arg `get-menu` and
re-applies it, which is how menus follow state changes.
Don't confuse this with `dialog/menu`, the modal picker — see
Dialogs.
## See Also
- App Platform — menus, pies, lifecycle
- Dialogs — `dialog/menu` and friends
- Deftlet — the `get-menu` contract method