# tui/menu-update
Re-evaluate the panel's `get-menu` function and update the menu bar.
This is a convenience wrapper around `tui/menu-set`. It resolves `get-menu` in the
calling panel's scope, calls it with no arguments, and passes the result to
`tui/menu-set`. If `get-menu` is not defined, the call is a no-op and returns `false`.
Call this from your app's event loop or whenever application state changes to keep
the menu bar in sync. For fully dynamic on-the-fly menus without a `get-menu`
function, use `tui/menu-set` directly.
## Syntax
[tui/menu-update]
## Parameters
None.
## Returns
`true` if `get-menu` was found, evaluated, and the result was stored successfully.
`false` if `get-menu` is not defined, or if the menu could not be parsed.
## Example
# Define a menu function that reflects current state def get-menu {|| set s [deref $state] %{ "File" @{ %MenuItem{ label "Save" action "menu-save" shortcut "Ctrl+S" } %MenuItem{ label [if $s~modified "Save As" "Export"] action "menu-save-as" shortcut "" } } } } # Call from the event loop to keep menus current def handle-event {|event| # ... process event, mutate state ... [tui/menu-update] } # Or call unconditionally each frame [tui start $layout %{ on-key $handle-key on-submit $handle-submit }] # In your key handler: def handle-key {key^string} { # ... handle key ... [tui/menu-update] # menu always reflects current state false }
## See also
- tui/menu-set — set menus directly from a map