Demonstrate creating a "main" fullscreen menu bar and populating it. Note the difference between BeginMainMenuBar() and BeginMenuBar(): - BeginMenuBar() = menu-bar inside current window (which needs the ImGuiWindowFlags_MenuBar flag!) - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it.
| 8768 | // - BeginMenuBar() = menu-bar inside current window (which needs the ImGuiWindowFlags_MenuBar flag!) |
| 8769 | // - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it. |
| 8770 | static void ShowExampleAppMainMenuBar() |
| 8771 | { |
| 8772 | if (ImGui::BeginMainMenuBar()) |
| 8773 | { |
| 8774 | if (ImGui::BeginMenu("File")) |
| 8775 | { |
| 8776 | IMGUI_DEMO_MARKER("Menu/File"); |
| 8777 | ShowExampleMenuFile(); |
| 8778 | ImGui::EndMenu(); |
| 8779 | } |
| 8780 | if (ImGui::BeginMenu("Edit")) |
| 8781 | { |
| 8782 | IMGUI_DEMO_MARKER("Menu/Edit"); |
| 8783 | if (ImGui::MenuItem("Undo", "Ctrl+Z")) {} |
| 8784 | if (ImGui::MenuItem("Redo", "Ctrl+Y", false, false)) {} // Disabled item |
| 8785 | ImGui::Separator(); |
| 8786 | if (ImGui::MenuItem("Cut", "Ctrl+X")) {} |
| 8787 | if (ImGui::MenuItem("Copy", "Ctrl+C")) {} |
| 8788 | if (ImGui::MenuItem("Paste", "Ctrl+V")) {} |
| 8789 | ImGui::EndMenu(); |
| 8790 | } |
| 8791 | ImGui::EndMainMenuBar(); |
| 8792 | } |
| 8793 | } |
| 8794 | |
| 8795 | // Note that shortcuts are currently provided for display only |
| 8796 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
no test coverage detected