From a727332e7727a912586c2ded504a0be1eabfa5dc Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 20 Sep 2024 18:08:13 +0200 Subject: [PATCH] Scrollbar: Shift+Click always use absolute positionning scroll. (#8002, #7328) --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8c1a815e9302..99ca1f13476a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -43,6 +43,8 @@ Breaking changes: Other changes: +- Scrollbar: Shift+Click always use absolute positionning scroll (which was the default + before 1.90.8). (#8002, #7328) - Backends: SDL3: Update for API changes: SDL_bool removal. SDL_INIT_TIMER removal. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index f2c5b8a0ce73..e50452eb63dc 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1000,8 +1000,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6 if (g.ActiveIdIsJustActivated) { // On initial click calculate the distance between mouse and the center of the grab - g.ScrollbarSeekMode = (short)held_dir; - g.ScrollbarClickDeltaToGrabCenter = (g.ScrollbarSeekMode == 0.0f) ? clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f : 0.0f; + g.ScrollbarSeekMode = g.IO.KeyShift ? 0 : (short)held_dir; + g.ScrollbarClickDeltaToGrabCenter = (g.ScrollbarSeekMode == 0 && !g.IO.KeyShift) ? clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f : 0.0f; } // Apply scroll (p_scroll_v will generally point on one member of window->Scroll)