-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows undocks from Dockspace when changing tabs #6505
Comments
Thank you for filling out the whole issue template and doing your due diligence! This is happening because the full ID of your dockspace is different depending on whether the tab item has focus. Dear ImGui IDs are stack-based, you can read more about this in this FAQ entry. Basically when tab The easiest solution in your case would be to calculate std::string d_id = "MyDockSpace" + std::to_string(n);
ImGuiID dockspace_id = ImGui::GetID(d_id.c_str());
if (ImGui::BeginTabItem(name, &open, ImGuiTabItemFlags_None))
{
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
}
ImGui::EndTabItem();
}
else
{
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_KeepAliveOnly);
} Some alternate solutions would be:
|
Ah! I see! I had just narrowed it down to being related to the dockspace_id, but didn't understand why. I change so I only used GetID once and then stored the value for each tab and saved the value, which solved the problem. With your explanation I also understand why :) If anyone else happens upon this, here is my working code: Thanks for the help! |
Thanks David for the help! Just for clarify: |
Version/Branch of Dear ImGui:
Version: 1.89.7 WIP
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: custom
Compiler: gcc 10.2.1
Operating System: Debian 11
My Issue/Question:
Windows get undocked when changing tab even when I call DockSpace with ImGuiDockNodeFlags_KeepAliveOnly for the hidden tabs. I have looked at issues #2599 and #2720 and I think I do as it says in those issues. Am I doing something wrong, or what should I do to make a DockSpace stay put inside a tab? I have mostly picked parts from imgui_demo.cpp
Screenshots/Video
A build off my code:
https://hka.github.io/test-imgui/
press the plus to create a second tab, press "Menu/New workspace" to get a window to dock, dock it and change tab.
Standalone, minimal, complete and verifiable example:
Not complete really but I guess this is the part where I do something wrong, for the rest of the code see
https://github.com/hka/test-imgui/blob/master/src/simple.cpp
not sure how make a more minimal example, very new to imgui.
The text was updated successfully, but these errors were encountered: