# tui/menu-set
Set the app menu bar from a map of menu-name → list of `%MenuItem{}`.
This is the low-level primitive for defining menus. Call it at any time with a
dynamically-constructed menu map — no `get-menu` function required. Use
`tui/menu-update` if you prefer to define a `get-menu` function and have the
workspace re-evaluate it automatically.
## Syntax
[tui/menu-set menus]
## Parameters
- `menus` — a map `%{ "File" @{ ... } "Edit" @{ ... } }` where each value is a
vector of `%MenuItem{ label "..." action "..." shortcut "..." }` tagged maps.
## Returns
`true` if the menu was parsed and stored successfully, `false` otherwise.
## Example
# Set a static menu [tui/menu-set %{ "File" @{ %MenuItem{ label "Open" action "menu-open" shortcut "Ctrl+O" } %MenuItem{ label "Save" action "menu-save" shortcut "Ctrl+S" } } "Edit" @{ %MenuItem{ label "Find" action "menu-find" shortcut "Ctrl+F" } } }] # Dynamically build a context-sensitive menu def make-menu {readonly^bool} { set items @{ %MenuItem{ label "Save" action "menu-save" shortcut "Ctrl+S" } } if (not $readonly) { set items (append $items %MenuItem{ label "Delete" action "menu-delete" shortcut "Del" }) } %{ "File" $items } } [tui/menu-set [make-menu false]]
## See also
- tui/menu-update — re-evaluate a `get-menu` function