From b8c6e31c2de36d80ed16af54b80ae8e489964f84 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 15 Jan 2019 15:05:56 +0100 Subject: [PATCH] Fixed cursor issue caused by 6890e08b when calling BeginChild/EndChild multiple times to reappend into a same child window. (#2282) --- imgui.cpp | 3 ++- imgui_demo.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index ac3580e3..9bdd8eed 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4276,7 +4276,8 @@ static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. // While this is not really documented/defined, it seems that the expected thing to do. - parent_window->DC.CursorPos = child_window->Pos; + if (child_window->BeginCount == 1) + parent_window->DC.CursorPos = child_window->Pos; // Process navigation-in immediately so NavInit can run on first frame if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll)) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index d5806401..c5cd34aa 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1983,7 +1983,7 @@ static void ShowDemoWindowLayout() { ImGui::BeginChild("scrolling"); // Demonstrate a trick: you can use Begin to set yourself in the context of another window (here we are already out of your child window) ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta); - ImGui::End(); + ImGui::EndChild(); } ImGui::TreePop(); }