瀏覽代碼

Fixed IsWindowFocused/IsWindowHovered with _ChildWindows for not following through popup parents (amend 6b1e094c, fix #4527)

ocornut 4 年之前
父節點
當前提交
92a39f78b9
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      imgui.cpp

+ 5 - 2
imgui.cpp

@@ -7268,8 +7268,11 @@ bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent,
     {
     {
         if (window == potential_parent)
         if (window == potential_parent)
             return true;
             return true;
-        if (window == (dock_hierarchy ? window->RootWindowDockTree : window->RootWindow))
-            return false;
+        // 2021-09-11: we broke the unexpressed contract that this function (prior to 6b1e094, #4527)
+        // would follow through popup parents as well. Restoring this for now. May want to add a ImGuiFocusedFlags_PopupHierarchy flag later.
+        if ((window->Flags & ImGuiWindowFlags_Popup) == 0)
+            if (window == (dock_hierarchy ? window->RootWindowDockTree : window->RootWindow))
+                return false;
         window = window->ParentWindow;
         window = window->ParentWindow;
     }
     }
     return false;
     return false;