Skip to content

Help with NavEnableGamepad and BeginMenu in Window (Not inside MainMenuBar)  #5730

@squirrelroad

Description

@squirrelroad
Dear ImGui 1.89 WIP (18825)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __APPLE__
define: __GNUC__=4
define: __clang_version__=12.0.5 (clang-1205.0.22.11)
--------------------------------
io.BackendPlatformName: imgui_impl_sdl
io.BackendRendererName: imgui_impl_sdlrenderer
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigMacOSXBehaviors
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Version/Branch of Dear ImGui:

Version: v1.88
Branch: tag v1.88

My Issue/Question:

Hi,
I would like to build my cheat menu with BeginMenu inside Window.
I am having trouble reaching MenuItem2 on the screenshot below using gamepad and keyboard.

Can you advice on how to solve this gamepad/keyboard navigation issue? Ideally I would like to use imgui solely on a gamepad (for console platforms)

Tested on Win64 as well.

Kind regards,

Screenshots/Video
Screen

Standalone, minimal, complete and verifiable example: (see #2261)

using example_sdl_sdlrenderer:

//
// ... ImGui::CreateContext();
// ... ImGuiIO& io = ImGui::GetIO(); (void)io;
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;     // Enable Keyboard Controls
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;      // Enable Gamepad Controls


/// ... ImGui::NewFrame();

        ImGui::Begin("MainMenu");
        if (ImGui::BeginMenu("Menu1"))
        {
            ImGui::MenuItem("MenuItem1");
            ImGui::EndMenu();
        }
        // ImGui::PushID("foo")
        if (ImGui::BeginMenu("Menu2"))
        {
            static float ff = 0.5;
            ImGui::SliderFloat("float1", &ff, 0.f, 1.f);
            ImGui::MenuItem("MenuItem2");
            ImGui::EndMenu();
        }
        // ImGui::PopID()
        if (ImGui::BeginMenu("Menu3"))
        {
            ImGui::MenuItem("MenuItem3");
            ImGui::EndMenu();
        }
        if (ImGui::BeginMenu("Menu4"))
        {
            ImGui::EndMenu();
        }
        ImGui::End();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmenusmenu bars, menu itemsnavkeyboard/gamepad navigation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions