From e2166db282140867d96f24326897a2b04d99ed14 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 3 May 2019 15:06:06 +0200 Subject: [PATCH] Internals: Fixed incorrect repeat delay/rate calculation in IsMouseClicked() with repeat flag leading to involontary but thankfully doubling the rate. Using our standard function, making the multiplicator explicit. --- imgui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 43afd235..361fa076 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4195,8 +4195,9 @@ bool ImGui::IsMouseClicked(int button, bool repeat) if (repeat && t > g.IO.KeyRepeatDelay) { - float delay = g.IO.KeyRepeatDelay, rate = g.IO.KeyRepeatRate; - if ((ImFmod(t - delay, rate) > rate*0.5f) != (ImFmod(t - delay - g.IO.DeltaTime, rate) > rate*0.5f)) + // FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold. + int amount = CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.5f); + if (amount > 0) return true; }