Skip to content

InputText inside a table inside the MainMenuBar instantly looses focus #8355

@arnaud-jamin

Description

@arnaud-jamin

Version/Branch of Dear ImGui:

v1.91.4

Back-ends:

example_win32_directx9

Compiler, OS:

Windows11 + MSVC 2022

Full config/build information:

Dear ImGui 1.91.4 (19140)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1942
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx9
io.ConfigFlags: 0x00000483
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1264.00,761.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

Details:

An InputText inside a table inside the MainMenuBar instantly looses focus.
Buttons are also unresponsive, but MenuItems are working.

The reason I'm using a table in the MainMenuBar is to right align some widgets.

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:

In the following code, the "TextInput2" is unresponsive:

ImGui::BeginMainMenuBar();

ImGui::SetNextItemWidth(200);
char buffer1[128] = {};
ImGui::InputTextWithHint("##TextInput1", "TextInput1", buffer1, sizeof(buffer1));

if (ImGui::BeginTable("##TableInMainMenuBar", 1, 0, ImVec2(-1, 0)))
{
    ImGui::TableSetupColumn("Col1");

    ImGui::TableNextRow();
    ImGui::TableNextColumn();

    ImGui::SetNextItemWidth(200);
    static char buffer2[128] = {};
    ImGui::InputTextWithHint("##TextInput2", "TextInput2", buffer2, sizeof(buffer2));

    ImGui::EndTable();
}

ImGui::EndMainMenuBar();

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions