ImGUI - Menu bar not showing up

118 Views Asked by At

I have the following code. A window pops up, but the menu bar does not. What am I doing wrong?

    ImGui::Begin("Example Window");

    // Create a menu bar
    if (ImGui::BeginMenuBar())
    {
        if (ImGui::BeginMenu("Menu"))
        {
            ImGui::MenuItem("Console");
        }

        ImGui::EndMenuBar();
    }
    ImGui::End();

Any help would be much appreciated.

1

There are 1 best solutions below

0
hugle On

You will need to set window flag with menu bar enabled:

if (ImGui::Begin("Example Window", nullptr, ImGuiWindowFlags_MenuBar)) {

    // Create a menu bar
    if (ImGui::BeginMenuBar())
    {
        if (ImGui::BeginMenu("Menu"))
        {
            ImGui::MenuItem("Console");
        }

        ImGui::EndMenuBar();
    }
    ImGui::End();
}