Commit 1988693

Nick committed on
Fix shift clicking
commit 198869333deb21a528c163f8b172f922efc49b85 parent 8633e65
1 changed files +19−3
Modifiedtrackergrid.pas +19−3
@@ -77,6 +77,7 @@ type
77 procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; 77 procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
78 procedure DblClick; override; 78 procedure DblClick; override;
79 procedure KeyDown(var Key: Word; Shift: TShiftState); override; 79 procedure KeyDown(var Key: Word; Shift: TShiftState); override;
80 procedure KeyUp(var Key: Word; Shift: TShiftState); override;
80 private 81 private
81 function GetSelection: TSelection; 82 function GetSelection: TSelection;
82 procedure PerformPaste(Paste: TSelection); overload; 83 procedure PerformPaste(Paste: TSelection); overload;
@@ -124,7 +125,8 @@ type
124 Selecting: Boolean; 125 Selecting: Boolean;
125 DraggingSelection: Boolean; 126 DraggingSelection: Boolean;
126 MouseMoveHappened: Boolean; 127 MouseMoveHappened: Boolean;
127 DragSelCursor, DragSelOther: TSelectionPos; 128 ShiftClicking: Boolean;
129 DragSelCursor, DragSelOther, ShiftClickOrigin: TSelectionPos;
128 DragOffsetY: Integer; 130 DragOffsetY: Integer;
129 131
130 NestedUndoCount: Integer; 132 NestedUndoCount: Integer;
@@ -325,8 +327,14 @@ begin
325 327
326 Clicked := MousePosToSelection(X, Y); 328 Clicked := MousePosToSelection(X, Y);
327 329
328 if ssShift in Shift then 330 if ssShift in Shift then begin
331 if not ShiftClicking then begin
332 ShiftClickOrigin := Cursor;
333 ShiftClicking := True;
334 end;
335 Cursor := ShiftClickOrigin;
329 Other := Clicked 336 Other := Clicked
337 end
330 else begin 338 else begin
331 if not SelectionsToRect(Cursor, Other).IntersectsWith(SelectionToRect(Clicked)) then begin 339 if not SelectionsToRect(Cursor, Other).IntersectsWith(SelectionToRect(Clicked)) then begin
332 Cursor := Clicked; 340 Cursor := Clicked;
@@ -392,7 +400,7 @@ var
392 begin 400 begin
393 inherited MouseUp(Button, Shift, X, Y); 401 inherited MouseUp(Button, Shift, X, Y);
394 402
395 if (not Selecting) and (not MouseMoveHappened) then begin 403 if (not Selecting) and (not MouseMoveHappened) and (not (ssShift in Shift)) then begin
396 Cursor := MousePosToSelection(X, Y); 404 Cursor := MousePosToSelection(X, Y);
397 Other := Cursor; 405 Other := Cursor;
398 end; 406 end;
@@ -471,6 +479,14 @@ begin
471 Invalidate 479 Invalidate
472 end; 480 end;
473 481
482 procedure TTrackerGrid.KeyUp(var Key: Word; Shift: TShiftState);
483 begin
484 inherited KeyUp(Key, Shift);
485
486 if key = VK_SHIFT then
487 ShiftClicking := False;
488 end;
489
474 function TTrackerGrid.GetSelection: TSelection; 490 function TTrackerGrid.GetSelection: TSelection;
475 var 491 var
476 R: Integer; 492 R: Integer;