Преглед изворни кода

ButtonBehavior(): ImGuiButtonFlags_PressedOnDoubleClick clears active id on double-click so that multiple flags don't trigger multiple times

ocornut пре 9 година
родитељ
комит
470b88e965
1 измењених фајлова са 2 додато и 7 уклоњено
  1. 2 7
      imgui.cpp

+ 2 - 7
imgui.cpp

@@ -1762,7 +1762,7 @@ bool ImGui::IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs)
     {
         ImGuiWindow* window = GetCurrentWindowRead();
         if (g.HoveredWindow == window || (flatten_childs && g.HoveredRootWindow == window->RootWindow))
-            if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowOverlap) && ImGui::IsMouseHoveringRect(bb.Min, bb.Max))
+            if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowOverlap) && IsMouseHoveringRect(bb.Min, bb.Max))
                 if (IsWindowContentHoverable(g.HoveredRootWindow))
                     return true;
     }
@@ -5279,17 +5279,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
                 SetActiveID(id, window); // Hold on ID
                 FocusWindow(window);
             }
-            if ((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0])
+            if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0]))
             {
                 pressed = true;
                 SetActiveID(0);
                 FocusWindow(window);
             }
-            if ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0])
-            {
-                pressed = true;
-                FocusWindow(window);
-            }
             if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0])
             {
                 pressed = true;