Skip to content

Commit c7d3d22

Browse files
committed
Scrolling: Mitigated issue where multi-axis mouse-wheel inputs (usually from touch pad events) are incorrectly locking scrolling in a parent window. (#4559, #3795, #2604)
1 parent 80a870a commit c7d3d22

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ Other Changes:
105105
achieve certains things (e.g. some ways to implement suggestion popup #718, #4461).
106106
- Scrolling: Tweak mouse-wheel locked window timer so it is shorter but also gets reset
107107
whenever scrolling again (#2604).
108+
- Scrolling: Mitigated issue where multi-axis mouse-wheel inputs (usually from touch pad
109+
events) are incorrectly locking scrolling in a parent window. (#4559, #3795, #2604)
108110
- InputText: added experimental io.ConfigInputTextEnterKeepActive feature to make pressing
109111
Enter keep the input active and select all text.
110112
- InputText: numerical fields automatically accept full-width characters (U+FF01..U+FF5E)

imgui.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -4299,15 +4299,17 @@ void ImGui::UpdateMouseWheel()
42994299
if (wheel_x == 0.0f && wheel_y == 0.0f)
43004300
return;
43014301

4302-
ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
4303-
if (!window || window->Collapsed)
4302+
//IMGUI_DEBUG_LOG("MouseWheel X:%.3f Y:%.3f\n", wheel_x, wheel_y);
4303+
ImGuiWindow* mouse_window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
4304+
if (!mouse_window || mouse_window->Collapsed)
43044305
return;
43054306

43064307
// Zoom / Scale window
43074308
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
43084309
if (wheel_y != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
43094310
{
4310-
LockWheelingWindow(window);
4311+
LockWheelingWindow(mouse_window);
4312+
ImGuiWindow* window = mouse_window;
43114313
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
43124314
const float scale = new_font_scale / window->FontWindowScale;
43134315
window->FontWindowScale = new_font_scale;
@@ -4338,11 +4340,12 @@ void ImGui::UpdateMouseWheel()
43384340
// Vertical Mouse Wheel scrolling
43394341
if (wheel_y != 0.0f)
43404342
{
4341-
LockWheelingWindow(window);
4343+
ImGuiWindow* window = mouse_window;
43424344
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
43434345
window = window->ParentWindow;
43444346
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
43454347
{
4348+
LockWheelingWindow(mouse_window);
43464349
float max_step = window->InnerRect.GetHeight() * 0.67f;
43474350
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
43484351
SetScrollY(window, window->Scroll.y - wheel_y * scroll_step);
@@ -4352,11 +4355,12 @@ void ImGui::UpdateMouseWheel()
43524355
// Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held
43534356
if (wheel_x != 0.0f)
43544357
{
4355-
LockWheelingWindow(window);
4358+
ImGuiWindow* window = mouse_window;
43564359
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
43574360
window = window->ParentWindow;
43584361
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
43594362
{
4363+
LockWheelingWindow(mouse_window);
43604364
float max_step = window->InnerRect.GetWidth() * 0.67f;
43614365
float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step));
43624366
SetScrollX(window, window->Scroll.x - wheel_x * scroll_step);

0 commit comments

Comments
 (0)