From 1963cc59bedf47f43872f8cc80a9aa5fc8ba40a6 Mon Sep 17 00:00:00 2001 From: Luca Rood Date: Sat, 16 Mar 2019 19:55:42 +0100 Subject: [PATCH] Implement horizontal scrolling with Shift+Scroll This is standard scrolling behaviour in most applications. --- imgui.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 41c56936..54e6125b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3296,6 +3296,13 @@ void ImGui::UpdateMouseWheel() window->Size *= scale; window->SizeFull *= scale; } + else if (!g.IO.KeyCtrl && g.IO.KeyShift && scroll_allowed) + { + // Mouse wheel horizontal scrolling + float scroll_amount = 5 * scroll_window->CalcFontSize(); + scroll_amount = (float)(int)ImMin(scroll_amount, (scroll_window->ContentsRegionRect.GetWidth() + scroll_window->WindowPadding.x * 2.0f) * 0.67f); + SetWindowScrollX(scroll_window, scroll_window->Scroll.x - g.IO.MouseWheel * scroll_amount); + } else if (!g.IO.KeyCtrl && scroll_allowed) { // Mouse wheel vertical scrolling