Skip to main content

Module menu

Module menu 

Source
Expand description

Declarative menu model — a single source of truth for both the in-window MenuBar and the platform’s native menu bar (NSMenu on macOS).

A MenuModel describes the whole menu tree as data — titles, intents, shortcut ids, enabled state, check / radio bindings, submenus, separators — with no built widgets. MenuBar::from_model renders it as the usual in-window dropdown bar, and the same model is mirrored into the OS menu bar via the native_on_macos flag. Reactive Signals drive both: a toggled check mark flips in the in-window menu and the native menu alike.

use teksilo::widgets::menu::{MenuModel, MenuEntry};
let model = MenuModel::new()
    .menu(tr!(file()), |m| m
        .item(MenuEntry::new(tr!(new())).intent("app.new").shortcut("app.new"))
        .separator()
        .item(MenuEntry::new(tr!(quit())).intent("app.quit")))
    .menu(tr!(view()), |m| m
        .item(MenuEntry::new(tr!(show_grid())).tri_checkable(grid_state)));

Re-exports§

pub use model::MenuEntry;
pub use model::MenuItemState;
pub use model::MenuItems;
pub use model::MenuModel;
pub use model::MenuNode;
pub use model::StandardMenu;
pub use native::NativeMenuMode;

Modules§

model
The MenuModel data type and its builders.
native
Bridge from a MenuModel to the platform native menu (teksilo-platform’s [NativeMenuHandle]).

Enums§

StandardMenuRole
Standard, platform-defined menus with required placement/behaviour (the macOS App / Window / Help menus, with their About / Hide / Quit / window-management items wired to system selectors). The backend supplies the native structure; the in-window MenuBar ignores these.