fix scrolling bug

This commit is contained in:
dan_s
2026-03-11 03:15:31 -05:00
parent 6bd5341507
commit 06c80ef51c

View File

@@ -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);
}
}
}