Skip to main content

Module menu

Module menu 

Source
Expand description

Menu action dispatch (§ menus). The model (day_spec::MenuItem) is toolkit-neutral and carries only ids for its actions; the closures live here, keyed by id. A backend fires Event::MenuAction(id) when a native item is chosen; the event pump routes it to dispatch_menu_action, which runs the app’s closure. Ids are process-unique and monotonic.

Enums§

MenuBarStyle
Arrange an app’s top-level menus into the platform’s standard bar, filling every standard slot the app did not claim with the backend’s stock menu.

Functions§

app_menu_installed
Whether any app menu was installed (an empty model = the backend default menu is up).
app_menu_model
The app menu as last installed (post-injection). The dayscript menu: step walks it to resolve an item’s dispatch id; backends re-read it on late preferences registration.
dispatch_menu_action
Run the closure registered for id (no-op if none). Called by the event pump on Event::MenuAction. Runs inside a reactive batch so multiple signal writes coalesce.
has_app_menu
Re-forward the retained model through the injection pass: the self-heal for register_preferences running after app_menu (docs/menus.md ordering note). Did the app install a menu model of its own (app_menu)? false means it is running on the backend’s default menu bar, which the backend builds before root() runs, so a backend that puts registration-dependent items there (Settings…, File ▸ New Window) has to rebuild it once the app’s registrations are in. day-toolkit-appkit does exactly that.
rebind_action
Register an app closure for a menu item and return its dispatch id (nonzero). The day-pieces menu builder calls this while lowering a menu tree to the day_spec::MenuItem model. Move the closure registered under from onto to, dropping from.
register_menu_action
register_scoped_menu_action
Register an app closure whose lifetime is tied to the current scope: the id is dropped from the dispatch map when that scope is disposed. This is the registrar for closures owned by a piece build (context menus, nav-row menus, nav bar_action), which are re-registered on every rebuild; without the cleanup each remount leaks the previous build’s closure (and whatever app state it captured) for the process lifetime.
reset_menus
Forget every menu action and the last-installed app menu: a re-mount (docs/settings.md “Appearance on Android”). The closures a previous mount registered capture that mount’s reactive graph, which has just been disposed; keeping them would leave the menu bar invoking a dead tree.
set_app_menu
set_dock_menu
Install the app’s Dock menu (docs/menus.md “Dock menu”): items go above the app’s [[shortcuts]] and the system’s own items when the user right-clicks the Dock icon (Cap::DockMenu, macOS). An empty vec leaves only the shortcuts. Replacing the menu drops the previous install’s action closures.
standard_menu_bar
leading are the slots before the app’s own menus and trailing the ones after; each backend passes its platform’s bar (macOS trails Window and Help; KDE trails Settings and Help; GNOME and Windows trail Help alone). stock returns the backend’s house version of a slot, or None where that platform has no such menu. Menus the app tagged with day_spec::MenuBarRole replace the stock one in place, so an app customizes a standard menu by claiming it rather than by rebuilding the whole bar.
standard_menu_bar_for
Assemble the bar for a desktop’s conventions: standard_menu_bar with that style’s slot order and stock menus.