Skip to content

Commit

Permalink
Fix dragging with the ScrollTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
pyscripter committed Nov 16, 2024
1 parent 515c304 commit 2a6ace8
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Source/SynEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2076,18 +2076,15 @@ procedure TCustomSynEdit.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
bWasSel: Boolean;
TmpBegin, TmpEnd: TBufferCoord;
P : TPoint;
// Ole drag drop
DragSource : IDropSource;
DataObject : IDataObject;
dwEffect : integer;
begin
// If Button = mbLeft MouseCapture is set by TControl.WMLButtonDown
inherited MouseDown(Button, Shift, X, Y);

TmpBegin := FSelection.Start;
TmpEnd := FSelection.Stop;

//remember selection state, as it will be cleared later
bWasSel := SelAvail;

Expand Down Expand Up @@ -2121,13 +2118,6 @@ procedure TCustomSynEdit.MouseDown(Button: TMouseButton; Shift: TShiftState;
// Check for drag and drop
if (Button = mbLeft) and (FSelections.Count = 1) then
begin
//I couldn't track down why, but sometimes (and definitely not all the time)
//the block positioning is lost. This makes sure that the block is
//maintained in case they started a drag operation on the block
FSelection.Start := TmpBegin;
FSelection.Stop := TmpEnd;

MouseCapture := True;
//if mousedown occurred in selected block begin drag operation
if bWasSel and (eoDragDropEditing in fOptions)
and (X >= fGutterWidth + fTextMargin)
Expand Down Expand Up @@ -2288,9 +2278,12 @@ procedure TCustomSynEdit.ScrollTimerHandler(Sender: TObject);
else if MouseCapture and (fClickCount = 3) then
// Line selection
DoMouseSelectLineRange(BC)
else if MouseCapture then
// if MouseCapture is True we're selecting with the mouse
MoveDisplayPosAndSelection(DC, True)
else
// if MouseCapture is True we're changing selection. otherwise we're dragging
MoveDisplayPosAndSelection(DC, MouseCapture);
// Ole dragging
InternalCaretXY := DisplayToBufferPos(DC);

// Deal with overlapping selections
Selections.MouseSelection(FSelection);
Expand All @@ -2310,6 +2303,7 @@ procedure TCustomSynEdit.MouseUp(Button: TMouseButton; Shift: TShiftState;
Index: Integer;
Rect: TRect;
begin
// If Button = mbLeft MouseCapture is stopped by TControl.WMLButtonUp
inherited MouseUp(Button, Shift, X, Y);
fKbdHandler.ExecuteMouseUp(Self, Button, Shift, X, Y);

Expand Down

0 comments on commit 2a6ace8

Please sign in to comment.