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
Back-ends: imgui_impl_glfw.cpp + imgui_impl_vulkan_with_textures.cpp
Operating System: Windows 11
My Issue/Question:
There seems to be a slight problem with the ImGui::SetWindowFocus function when trying to focus a newly created docked window, where if you call ImGui::SetWindowFocus immediately after the first call to ImGui::Begin (e.g immediately after the window has been created and docked for the first time) the call is ignored.
This essentially means that you as the user of ImGui have to delay the call until afterImGui::Begin has been called for the second time, which is a bit annoying.
I ran into this issue when I was trying to make it so that when a new tab is opened for the first time (in a dockspace) that tab would be focused, and it would be great if ImGui would handle this internally since it can be really confusing when it simply doesn't work.
I will note that this is not an issue when focusing a newly created window that isn't docked immediately after creation.
Again, it's possible to work around this issue pretty easily but it can be confusing when encountering the issue for the first time.
Example Code:
staticbool s_RebuildDockspace = true;
static ImGuiID s_DockSpaceID;
{
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar;
ImGui::Begin("Dockspace", nullptr, window_flags);
if (s_RebuildDockspace)
{
s_DockSpaceID = ImGui::GetID("TestDockspace");
ImGui::DockBuilderRemoveNode(s_DockSpaceID);
ImGuiID rootNode = ImGui::DockBuilderAddNode(s_DockSpaceID, ImGuiDockNodeFlags_DockSpace);
ImGui::DockBuilderFinish(s_DockSpaceID);
}
ImGui::DockSpace(s_DockSpaceID, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoWindowMenuButton);
{
ImGui::Begin("Panel 0");
if (s_RebuildDockspace)
ImGui::DockBuilderDockWindow("Panel 0", s_DockSpaceID);
ImGui::Text("Hello");
ImGui::End();
}
ImGui::Begin("Panel 1");
if (s_RebuildDockspace)
ImGui::DockBuilderDockWindow("Panel 1", s_DockSpaceID);
ImGui::Text("Hello Again");
ImGui::End();
ImGui::End();
}
s_RebuildDockspace = false;
if (s_FirstFrame)
{
// Will not set focus to Panel 1 unless we've called ImGui::Begin at least 2 timesImGui::SetWindowFocus("Panel 1");
s_FirstFrame = false;
}
The text was updated successfully, but these errors were encountered:
I ran into this issue when I was trying to make it so that when a new tab is opened for the first time (in a dockspace) that tab would be focused, and it would be great if ImGui would handle this internally since it can be really confusing when it simply doesn't work.
This is planned and desirable (#2304). I had a 90% working solution last year but it had complications and never got around to finish it fully.
Note that reopening multiple docked windows at the same time (same frame) should restore focus, but it's currently a bit of a mess.
Yeah, in that case I'll probably continue delaying the call until after the second time that ImGui::Begin has been called, it seems to work reliably so
Version/Branch of Dear ImGui:
Version: 1.87 (18701)
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_vulkan_with_textures.cpp
Operating System: Windows 11
My Issue/Question:
There seems to be a slight problem with the
ImGui::SetWindowFocus
function when trying to focus a newly created docked window, where if you callImGui::SetWindowFocus
immediately after the first call toImGui::Begin
(e.g immediately after the window has been created and docked for the first time) the call is ignored.This essentially means that you as the user of ImGui have to delay the call until after
ImGui::Begin
has been called for the second time, which is a bit annoying.I ran into this issue when I was trying to make it so that when a new tab is opened for the first time (in a dockspace) that tab would be focused, and it would be great if ImGui would handle this internally since it can be really confusing when it simply doesn't work.
I will note that this is not an issue when focusing a newly created window that isn't docked immediately after creation.
Again, it's possible to work around this issue pretty easily but it can be confusing when encountering the issue for the first time.
Example Code:
The text was updated successfully, but these errors were encountered: