Переглянути джерело

Disabled: items more consistently release active id if the active item got disabled. (#211) (amend 2952525)

ocornut 4 роки тому
батько
коміт
246ad6c03c
2 змінених файлів з 3 додано та 4 видалено
  1. 3 0
      imgui.cpp
  2. 0 4
      imgui_widgets.cpp

+ 3 - 0
imgui.cpp

@@ -3234,6 +3234,9 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
     // When disabled we'll return false but still set HoveredId
     if (g.CurrentItemFlags & ImGuiItemFlags_Disabled)
     {
+        // Release active id if turning disabled
+        if (g.ActiveId == id)
+            ClearActiveID();
         g.HoveredIdDisabled = true;
         return false;
     }

+ 0 - 4
imgui_widgets.cpp

@@ -611,10 +611,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
         }
     }
 
-    // Release active id if turning disabled
-    if (g.ActiveId == id && (g.CurrentItemFlags & ImGuiItemFlags_Disabled))
-        ClearActiveID();
-
     // Process while held
     bool held = false;
     if (g.ActiveId == id)