fix scrolling bug
This commit is contained in:
@@ -757,15 +757,26 @@ 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
|
||||||
bool popupOpen = ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel);
|
// return false when an ActiveId exists (focused input, held button) or
|
||||||
if (!popupOpen && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows)) {
|
// when tooltip/popup windows from row hovers interfere with hover
|
||||||
float wheel = ImGui::GetIO().MouseWheel;
|
// routing. Still skip when a real popup (combo dropdown, context menu)
|
||||||
if (wheel != 0.0f) {
|
// is open so the popup handles its own scrolling.
|
||||||
float step = ImGui::GetTextLineHeightWithSpacing() * 3.0f;
|
{
|
||||||
s.target -= wheel * step;
|
bool popupOpen = ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel);
|
||||||
s.target = ImClamp(s.target, 0.0f, scrollMaxY);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user