diff options
author | Neil <nyamatongwe@gmail.com> | 2023-11-06 08:05:42 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2023-11-06 08:05:42 +1100 |
commit | c32f6adbe3ba88dc14839280213578c7656d2e38 (patch) | |
tree | 52275a43d74d7650d19ec7376569c7d09648fe2d | |
parent | 1272f93ac3afd3892d04364fdc5abba56161951d (diff) | |
download | scintilla-mirror-c32f6adbe3ba88dc14839280213578c7656d2e38.tar.gz |
Mouse capture and automatic scrolling are always started and stopped together so
encapsulate that in ChangeMouseCapture method.
Does not change behaviour.
-rw-r--r-- | src/Editor.cxx | 27 | ||||
-rw-r--r-- | src/Editor.h | 1 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index d498cc0d7..d65c8aea3 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4403,8 +4403,6 @@ bool Editor::DragThreshold(Point ptStart, Point ptNow) { void Editor::StartDrag() { // Always handled by subclasses - //SetMouseCapture(true); - //DisplayCursor(Windows::Cursor::Arrow); } void Editor::DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular) { @@ -4684,8 +4682,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi } if ((curTime < (lastClickTime+Platform::DoubleClickTime())) && Close(pt, lastClick, doubleClickCloseThreshold)) { //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime); - SetMouseCapture(true); - FineTickerStart(TickReason::scroll, 100, 10); + ChangeMouseCapture(true); if (!ctrl || !multipleSelection || (selectionUnit != TextUnit::character && selectionUnit != TextUnit::word)) SetEmptySelection(newPos.Position()); bool doubleClick = false; @@ -4783,8 +4780,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi } SetDragPosition(SelectionPosition(Sci::invalidPosition)); - SetMouseCapture(true); - FineTickerStart(TickReason::scroll, 100, 10); + ChangeMouseCapture(true); } else { if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newCharPos.Position(), modifiers); @@ -4796,8 +4792,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi else inDragDrop = DragDrop::none; } - SetMouseCapture(true); - FineTickerStart(TickReason::scroll, 100, 10); + ChangeMouseCapture(true); if (inDragDrop != DragDrop::initial) { SetDragPosition(SelectionPosition(Sci::invalidPosition)); if (!shift) { @@ -4914,8 +4909,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) { if (inDragDrop == DragDrop::initial) { if (DragThreshold(ptMouseLast, pt)) { - SetMouseCapture(false); - FineTickerCancel(TickReason::scroll); + ChangeMouseCapture(false); SetDragPosition(movePos); CopySelectionRange(&drag); StartDrag(); @@ -5057,8 +5051,7 @@ void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, KeyMod modifi SetHotSpotRange(nullptr); } ptMouseLast = pt; - SetMouseCapture(false); - FineTickerCancel(TickReason::scroll); + ChangeMouseCapture(false); NotifyIndicatorClick(false, newPos.Position(), modifiers); if (inDragDrop == DragDrop::dragging) { const SelectionPosition selStart = SelectionStart(); @@ -5191,6 +5184,16 @@ void Editor::FineTickerCancel(TickReason) { assert(false); } +void Editor::ChangeMouseCapture(bool on) { + SetMouseCapture(on); + // While mouse captured want timer to scroll automatically + if (on) { + FineTickerStart(TickReason::scroll, 100, 10); + } else { + FineTickerCancel(TickReason::scroll); + } +} + void Editor::SetFocusState(bool focusState) { const bool changing = hasFocus != focusState; hasFocus = focusState; diff --git a/src/Editor.h b/src/Editor.h index 923e3b7a3..b1b426dff 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -548,6 +548,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void FineTickerStart(TickReason reason, int millis, int tolerance); virtual void FineTickerCancel(TickReason reason); virtual bool SetIdle(bool) { return false; } + void ChangeMouseCapture(bool on); virtual void SetMouseCapture(bool on) = 0; virtual bool HaveMouseCapture() = 0; void SetFocusState(bool focusState); |