Skip to main content

MenuBar

#include "toolkit/menubar.hpp"

A horizontal bar of top-level Menus (File, Edit, …), with mnemonic (Alt+letter) keyboard navigation between them. Inherits Widget.

MenuBar screenshot

Example​

auto menubar = std::make_unique<toolkit::MenuBar>();
auto file_menu = menubar->add_menu("&File");
file_menu->add_action("&Open…", [] { open_file(); });

Construction​

MenuBar();

API​

MemberDescription
add_menu(std::shared_ptr<Menu>)Add an existing menu
add_menu(std::string title) → std::shared_ptr<Menu>Create, add, and return a new menu
toggle_menu(int index)Open/close a top-level menu programmatically
find_menu(std::string_view title)Look up a menu's index by title
set_show_mnemonics(bool)Show underlined mnemonics (normally only while Alt is held)