From 06c80ef51c44f1bd5949df83de737e0eda606f99 Mon Sep 17 00:00:00 2001 From: dan_s Date: Wed, 11 Mar 2026 03:15:31 -0500 Subject: [PATCH] fix scrolling bug --- src/ui/material/draw_helpers.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/ui/material/draw_helpers.h b/src/ui/material/draw_helpers.h index bbbc299..d878c07 100644 --- a/src/ui/material/draw_helpers.h +++ b/src/ui/material/draw_helpers.h @@ -757,15 +757,26 @@ inline void ApplySmoothScroll(float speed = 12.0f) s.current = actualY; } - // Capture mouse wheel when hovered, but not when a popup (combo dropdown - // etc.) is open — let the popup handle its own scrolling exclusively. - bool popupOpen = ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel); - if (!popupOpen && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) { - float wheel = ImGui::GetIO().MouseWheel; - if (wheel != 0.0f) { - float step = ImGui::GetTextLineHeightWithSpacing() * 3.0f; - s.target -= wheel * step; - s.target = ImClamp(s.target, 0.0f, scrollMaxY); + // Capture mouse wheel when the cursor is inside this child window. + // Use a direct position check instead of IsWindowHovered() which can + // return false when an ActiveId exists (focused input, held button) or + // when tooltip/popup windows from row hovers interfere with hover + // routing. Still skip when a real popup (combo dropdown, context menu) + // is open so the popup handles its own scrolling. + { + bool popupOpen = ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel); + ImVec2 mpos = ImGui::GetIO().MousePos; + ImVec2 wmin = win->Pos; + ImVec2 wmax = ImVec2(wmin.x + win->Size.x, wmin.y + win->Size.y); + bool inside = (mpos.x >= wmin.x && mpos.x < wmax.x && + mpos.y >= wmin.y && mpos.y < wmax.y); + if (!popupOpen && inside) { + float wheel = ImGui::GetIO().MouseWheel; + if (wheel != 0.0f) { + float step = ImGui::GetTextLineHeightWithSpacing() * 3.0f; + s.target -= wheel * step; + s.target = ImClamp(s.target, 0.0f, scrollMaxY); + } } }