Skip to main content

menu_bar

Function menu_bar 

Source
pub fn menu_bar(ui: &mut Ui<'_>, bar: MenuBar)
Expand description

The application menu: bar is what the app’s menu is, and calling this is where its titles go when they have to be drawn in the window.

One call and not two, because the declaration and the placement are one decision. It draws nothing where the platform owns the bar — macOS, where the driver hands this same declaration to NSApp — so the call still says what the menu is and the strip simply is not there; that is the contract window_buttons has under native decorations, and it is what makes one view portable. An empty bar takes the menu away.

Declared every frame, and diffed: an unchanged menu costs a comparison and rebuilds nothing.

Everything below a title is the stock menu: the same rows, roles, accelerators and access tree the context menu draws, through the same menu_panel. What is the bar’s own is the scope — while a menu is open the bar is the frame’s modal, not the dropdown, so hovering across the titles moves the open menu the way a menu bar does, a press on the open title closes it, and Escape or a press in the app below dismisses it as any modal is dismissed.

Typical use, as the first child of a full-height root, under the titlebar if there is one: widgets::menu_bar(ui, self.menu());