Guide API
Skip to main content

Module menu_bar

Module menu_bar 

Source
Expand description

The horizontal menu bar.

MenuBar is a one-row MenuView that lays its top-level items out left-to-right. The bar-specific work is its layout — draw and get_item_rect. Its handle_event delegates to the shared passive menu_view::handle_event, which handles the command-graying broadcast, posts an accelerator’s command, and opens the menu session on a bar hotkey.

Because MenuViewState embeds a ViewState (not a View), the differing View methods (state/state_mut/draw/handle_event) are hand-written, like ListBox, rather than generated by the #[delegate] macro.

A menu bar holding a startup-disabled command would draw it enabled until the first command-set-changed broadcast, which does not fire at startup; so Program::new seeds each inserted bar by calling update_menu_commands directly with the initial disabled-command set.

§Turbo Vision heritage

Ports TMenuBar (tmenubar.cpp/menus.h). The TMenuView base becomes the MenuView trait (deviation D2); the disabled-command set is held as a denylist (deviation D1) and TStreamable persistence is dropped (deviation D12).

Structs§

MenuBar
The horizontal menu bar. Holds the shared MenuViewState; the bar-specific layout lives in draw / get_item_rect.