fix scrolling bug

This commit is contained in:
2026-03-11 03:15:31 -05:00
parent 853e3e0f17
commit 4023af9466

View File

@@ -757,10 +757,20 @@ inline void ApplySmoothScroll(float speed = 12.0f)
s.current = actualY; s.current = actualY;
} }
// Capture mouse wheel when hovered, but not when a popup (combo dropdown // Capture mouse wheel when the cursor is inside this child window.
// etc.) is open — let the popup handle its own scrolling exclusively. // 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); bool popupOpen = ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel);
if (!popupOpen && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) { 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; float wheel = ImGui::GetIO().MouseWheel;
if (wheel != 0.0f) { if (wheel != 0.0f) {
float step = ImGui::GetTextLineHeightWithSpacing() * 3.0f; float step = ImGui::GetTextLineHeightWithSpacing() * 3.0f;
@@ -768,6 +778,7 @@ inline void ApplySmoothScroll(float speed = 12.0f)
s.target = ImClamp(s.target, 0.0f, scrollMaxY); s.target = ImClamp(s.target, 0.0f, scrollMaxY);
} }
} }
}
// Clamp target if scrollMax changed (e.g., content resized) // Clamp target if scrollMax changed (e.g., content resized)
if (s.target > scrollMaxY) s.target = scrollMaxY; if (s.target > scrollMaxY) s.target = scrollMaxY;