From e001ec91f3455f5cdc6f2a9216129b85605989cf Mon Sep 17 00:00:00 2001 From: Joel Blanco Berg Date: Fri, 3 Jan 2025 11:36:31 +0100 Subject: [PATCH] Code Editor: scroll and select (#7948) * Makes it possible to mousewheel scroll and select text at the same time. * Shift + mousewheel scrolls sideways --- src/surge-xt/gui/overlays/LuaEditors.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/surge-xt/gui/overlays/LuaEditors.cpp b/src/surge-xt/gui/overlays/LuaEditors.cpp index 2a649faf60a..f56aec8af6a 100644 --- a/src/surge-xt/gui/overlays/LuaEditors.cpp +++ b/src/surge-xt/gui/overlays/LuaEditors.cpp @@ -1117,7 +1117,18 @@ void SurgeCodeEditorComponent::mouseWheelMove(const juce::MouseEvent &e, { juce::MouseWheelDetails w(wheel); w.deltaY *= 4; - CodeEditorComponent::mouseWheelMove(e, w); + + // makes it possible to mouse wheel scroll and select text at the same time + if (e.mods.isShiftDown()) + { + auto scrollbar = dynamic_cast(getChildren()[1]); + auto pos = scrollbar->getCurrentRange().getStart(); + scrollToColumn(pos - w.deltaY * 10); + } + else + { + scrollBy(-w.deltaY * 10); + } } // Handles auto indentation