From 15a93d6fe39cde690fe35fca8e921878fd0c89be Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 30 Jul 2018 14:36:08 +0200 Subject: [PATCH] Internals: Fixed HoveredIdTimer so it is safe to call SetHoveredId() multiple times without altering the timer. --- imgui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 10f01baee..41cd5be80 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2285,7 +2285,8 @@ void ImGui::SetHoveredID(ImGuiID id) ImGuiContext& g = *GImGui; g.HoveredId = id; g.HoveredIdAllowOverlap = false; - g.HoveredIdTimer = (id != 0 && g.HoveredIdPreviousFrame == id) ? (g.HoveredIdTimer + g.IO.DeltaTime) : 0.0f; + if (id != 0 && g.HoveredIdPreviousFrame != id) + g.HoveredIdTimer = 0.0f; } ImGuiID ImGui::GetHoveredID() @@ -3897,6 +3898,8 @@ void ImGui::NewFrame() // Clear reference to active widget if the widget isn't alive anymore if (!g.HoveredIdPreviousFrame) g.HoveredIdTimer = 0.0f; + if (g.HoveredId) + g.HoveredIdTimer += g.IO.DeltaTime; g.HoveredIdPreviousFrame = g.HoveredId; g.HoveredId = 0; g.HoveredIdAllowOverlap = false;