You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often use SetKeyboardFocusHere() to focus an InputText() after some event has happened.
Since commit 70f2aaf, this works only if the current focus scope contains the InputText() in question.
I understand that this is because SetKeyboardFocusHere() is treated as a tabbing request and starting from the mentioned commit, it is required to set ImGuiWindowFlags_NavFlattened to be able to tab between child windows.
I do not want to enable this flag however, but still want to be able to programmatically switch focus like before.
One workaround currently is to call SetWindowFocus() before SetKeyboardFocusHere(), see the attached code example.
Would it be possible to skip this check: if (g.NavFocusScopeId != g.CurrentFocusScopeId)
in NavProcessItemForTabbingRequest() when the tabbing request came from SetKeyboardFocusHere()?
Kind regards.
Screenshots/Video:
imgui-focus.mp4
Minimal, Complete and Verifiable Example code:
ImGui::Begin("Test", 0, ImGuiWindowFlags_AlwaysAutoResize);
unsigned child_flags = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysAutoResize | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY;
ImGui::BeginChild("Child1", ImVec2(), child_flags);
bool focus_InputText = false;
if (ImGui::Button("Focus InputText in other child"))
focus_InputText = true;
ImGui::EndChild();
ImGui::BeginChild("Child2", ImVec2(), child_flags);
if (ImGui::Button("Focus InputText in this child"))
focus_InputText = true;
char buf[32];
snprintf(buf, sizeof buf, "Some text");
if (focus_InputText)
{
// ImGui::SetWindowFocus(); // Un-comment this to allow the top Button() to focus the InputText().ImGui::SetKeyboardFocusHere();
}
ImGui::InputText("##Text", buf, sizeof buf, ImGuiInputTextFlags_AutoSelectAll);
ImGui::EndChild();
ImGui::End();
The text was updated successfully, but these errors were encountered:
Version/Branch of Dear ImGui:
Version 1.90.1, Branch: master
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Linux + GCC
Full config/build information:
Details:
My Issue/Question:
Hello,
I often use SetKeyboardFocusHere() to focus an InputText() after some event has happened.
Since commit 70f2aaf, this works only if the current focus scope contains the InputText() in question.
I understand that this is because SetKeyboardFocusHere() is treated as a tabbing request and starting from the mentioned commit, it is required to set ImGuiWindowFlags_NavFlattened to be able to tab between child windows.
I do not want to enable this flag however, but still want to be able to programmatically switch focus like before.
One workaround currently is to call SetWindowFocus() before SetKeyboardFocusHere(), see the attached code example.
Would it be possible to skip this check:
if (g.NavFocusScopeId != g.CurrentFocusScopeId)
in NavProcessItemForTabbingRequest() when the tabbing request came from SetKeyboardFocusHere()?
Kind regards.
Screenshots/Video:
imgui-focus.mp4
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: