Skip to main content

BeginMenuBar

Append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window).
bool
True if menu bar is open. Only call EndMenuBar() if this returns true.

EndMenuBar

Close menu bar. Only call EndMenuBar() if BeginMenuBar() returns true.

BeginMainMenuBar

Create and append to a full screen menu-bar.
bool
True if menu bar is open. Only call EndMainMenuBar() if this returns true.

EndMainMenuBar

Close main menu bar. Only call EndMainMenuBar() if BeginMainMenuBar() returns true.

BeginMenu

Create a sub-menu entry. Only call EndMenu() if this returns true.
const char*
Menu label
bool
default:"true"
Whether the menu is enabled (grayed out if false)
bool
True when menu is open

EndMenu

Close menu. Only call EndMenu() if BeginMenu() returns true.
Menu item. Returns true when activated.
const char*
Menu item label
const char*
default:"NULL"
Keyboard shortcut text (display only, not processed by ImGui)
bool
default:"false"
Whether the item is selected (displays checkmark)
bool
default:"true"
Whether the item is enabled
bool
True when activated
Menu item with pointer to selection state. Returns true when activated, and toggles *p_selected if p_selected != NULL.
const char*
Menu item label
const char*
Keyboard shortcut text
bool*
Pointer to selection state (automatically toggled)
bool
default:"true"
Whether the item is enabled
bool
True when activated

Complete Example

Notes

  • MenuItem keyboard shortcuts are displayed but NOT processed by Dear ImGui. You need to handle keyboard input yourself.
  • You can use ## in labels to hide text after it (useful for creating unique IDs).
  • Menus can be nested to any depth.
  • Use ImGui::Separator() to add horizontal lines between menu items.
  • MenuItem returns true on activation, which happens on mouse release (not press).