From 56c071e2734e3812c7c77b611637cbc2698eb7d3 Mon Sep 17 00:00:00 2001 From: Nathaniel Braun Date: Thu, 8 Jan 2026 08:22:01 +1100 Subject: Feature [feature-requests:#184]. Add option to disable drag/drop editing SCI_SETDRAGDROPENABLED. Fully implemented on Win32 but may only prevent dragging on other platforms. --- src/Editor.cxx | 12 ++++++++++-- src/Editor.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index 1ad99c3ca..a2c3e0fe9 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -143,6 +143,7 @@ Editor::Editor() : durationWrapOneByte(0.000001, 0.00000001, 0.00001) { dwelling = false; ptMouseLast.x = 0; ptMouseLast.y = 0; + dragDropEnabled = true; inDragDrop = DragDrop::none; dropWentOutside = false; posDrop = SelectionPosition(Sci::invalidPosition); @@ -5041,7 +5042,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) { AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position()); - if (inDragDrop == DragDrop::initial) { + if (dragDropEnabled && inDragDrop == DragDrop::initial) { if (DragThreshold(ptMouseLast, pt)) { ChangeMouseCapture(false); SetDragPosition(movePos); @@ -5139,7 +5140,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) { } } // Display regular (drag) cursor over selection - if (PointInSelection(pt) && !SelectionEmpty()) { + if (PointInSelection(pt) && !SelectionEmpty() && dragDropEnabled) { DisplayCursor(Window::Cursor::arrow); SetHoverIndicatorPosition(Sci::invalidPosition); } else { @@ -7084,6 +7085,13 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::GetBufferedDraw: return view.bufferedDraw; + case Message::GetDragDropEnabled: + return dragDropEnabled; + + case Message::SetDragDropEnabled: + dragDropEnabled = wParam != 0; + break; + #ifdef INCLUDE_DEPRECATED_FEATURES case SCI_GETTWOPHASEDRAW: return view.phasesDraw == EditView::phasesTwo; diff --git a/src/Editor.h b/src/Editor.h index f8bc18970..95b83f1f7 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -238,6 +238,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool dwelling; enum class TextUnit { character, word, subLine, wholeLine } selectionUnit; Point ptMouseLast; + bool dragDropEnabled; enum class DragDrop { none, initial, dragging } inDragDrop; bool dropWentOutside; SelectionPosition posDrop; -- cgit v1.2.3