Skip to content

SetKeyboardFocusHere() does not work with InputTextMultiline + ImGuiInputTextFlags_AllowTabInput #8928

Closed

Description

@Counter-clock

Version/Branch of Dear ImGui:

Version 1.92.2b, Branch: master

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx11.cpp

Compiler, OS:

Windows 11 + MSVC 2022

Details:

Using SetKeyboardFocusHere() with InputTextMultiline() and the ImGuiInputTextFlags_AllowTabInput flag, does not make the item keyboard focused, as it should.

In contrast, using it with InputTextMultiline() alone works as expected and InputText() behaves correctly with or without the ImGuiInputTextFlags_AllowTabInput flag.

Issue Example:

static char buf[256] = "";
static bool focusInput = false;

if (ImGui::Button("Focus Input"))
    focusInput = true;

if (focusInput) {
    ImGui::SetKeyboardFocusHere(0);
    focusInput = false;
}

ImGui::InputTextMultiline("##TextInput", buf, IM_ARRAYSIZE(buf), ImVec2(350.0f, 200.0f), ImGuiInputTextFlags_AllowTabInput );

Activity

  1. ocornut commented on Sep 10, 2025

    @ocornut
    Owner

    Hello,
    Thank you for your report and careful repro.
    This is now fixed by 2f1d1c8.

    This was caused by the fact that we have special handling for InputText() with ImGuiInputTextFlags_AllowTabInput, they inhibit activation during tabbing in order to allow cycling through multiple items. As SetKeyboardFocusHere(0) internally uses some of the tabbing logic this behavior leaked in that situation. Now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址