Skip to content

ImGui::InputText doesn't work properly with dockspaces #4375

@Lucas-Czerny

Description

@Lucas-Czerny

Version/Branch of Dear ImGui:

Version: v1.79 WIP
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler: MSVC v142 - Visual Studio 2019 (not entirely sure about msvc version, should be irrelevant though)
Operating System: Windows 10 Pro; Version: 10.0.19042 Build 19042

My Issue/Question:

I have a weird issue using an ImGui::InputText in a dockspace window. I have a Properties Window containing the InputText. When the Properties Window isn't docked, the InputText works perfectly fine. However, if I dock my Properties Window, I cannot input anything. If I click on the InputText, it immediately seems to lose focus, because I start dragging the window (even though I set the flag that you can only drag a window by its title bar).
In the video, you can see how I cannot use the InputText if the window is docked, then I drag the window out of the dockspace, grabbing it by the input text (which shouldnt be possible). When the window is undocked, the InputText works.

Screenshots/Video

here's a youtube link, because the file was too big
https://www.youtube.com/watch?v=fRXyaAJel1A

Standalone, minimal, complete and verifiable example:

First of all, you need to create a dockspace window (I did it like this):

static bool open = true;

static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;

ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;

ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->GetWorkPos());
ImGui::SetNextWindowSize(viewport->GetWorkSize());
ImGui::SetNextWindowViewport(viewport->ID);

window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;

ImGui::Begin("DockSpace Demo", &open, window_flags);

ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);

I have those config flags set:

ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;       // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;           // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;         // Enable Multi-Viewport / Platform Windows

io.ConfigWindowsMoveFromTitleBarOnly = true;

Then, create a Properties Window like this:

ImGui::Begin("Properties");

static char tagBuffer[256];

memset(tagBuffer, '\0', sizeof(tagBuffer));
strcpy_s(tagBuffer, sizeof(tagBuffer), "Test");

if (ImGui::InputText("", tagBuffer, sizeof(tagBuffer)))
{
    // ...
}

ImGui::End();

Now dock the Properties window to the dockspace, and you should see that you can't input anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions