Menu Bars
Window Menu Bar
Add a menu bar to the current window:Requires
ImGuiWindowFlags_MenuBar flag set on the parent window.Main Menu Bar
Create a full-screen menu bar at the top:Menu Items
BeginMenu() / EndMenu()
Create a sub-menu:const char*
required
Menu label
bool
default:"true"
Whether the menu can be opened
MenuItem()
Create a clickable menu item:const char*
required
Menu item label
const char*
Keyboard shortcut text (for display only, not processed)
bool
Display a checkmark if true
bool
default:"true"
Whether the item can be clicked
Nested Menus
Create hierarchical menu structures:Menu Separators
Add visual separators between menu items:Context Menus
BeginPopupContextItem()
Context menu for the last item:BeginPopupContextWindow()
Context menu for the current window:BeginPopupContextVoid()
Context menu when clicking in empty space:Complex Menu Contents
Menus can contain any widgets:Menu with Colors
Display color swatches in menus:Appending to Existing Menus
You can append to menus multiple times:Complete Example
Best Practices
Keyboard shortcuts in
MenuItem() are displayed but not automatically processed. You need to implement the actual keyboard handling separately.