Zak
Zak

Reputation: 41

ImGUI - Menu bar not showing up

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.

Upvotes: 0

Views: 976

Answers (1)

hugle
hugle

Reputation: 145

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();
}

Upvotes: 0

Related Questions