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.
| 8861 | // - BeginMenuBar() = menu-bar inside current window (which needs the ImGuiWindowFlags_MenuBar flag!) |
| 8862 | // - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it. |
| 8863 | static void ShowExampleAppMainMenuBar() |
| 8864 | { |
| 8865 | if (ImGui::BeginMainMenuBar()) |
| 8866 | { |
| 8867 | if (ImGui::BeginMenu("File")) |
| 8868 | { |
| 8869 | IMGUI_DEMO_MARKER("Menu/File"); |
| 8870 | ShowExampleMenuFile(); |
| 8871 | ImGui::EndMenu(); |
| 8872 | } |
| 8873 | if (ImGui::BeginMenu("Edit")) |
| 8874 | { |
| 8875 | IMGUI_DEMO_MARKER("Menu/Edit"); |
| 8876 | if (ImGui::MenuItem("Undo", "Ctrl+Z")) {} |
| 8877 | if (ImGui::MenuItem("Redo", "Ctrl+Y", false, false)) {} // Disabled item |
| 8878 | ImGui::Separator(); |
| 8879 | if (ImGui::MenuItem("Cut", "Ctrl+X")) {} |
| 8880 | if (ImGui::MenuItem("Copy", "Ctrl+C")) {} |
| 8881 | if (ImGui::MenuItem("Paste", "Ctrl+V")) {} |
| 8882 | ImGui::EndMenu(); |
| 8883 | } |
| 8884 | ImGui::EndMainMenuBar(); |
| 8885 | } |
| 8886 | } |
| 8887 | |
| 8888 | // Note that shortcuts are currently provided for display only |
| 8889 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
no test coverage detected