diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index e4a89361da..37b37d327e 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -66,8 +66,9 @@ type dgHeaderHotTracking, dgHeaderPushedLook, dgPersistentMultiSelect, - dgAutoSizeColumns - + dgAutoSizeColumns, + dgCanSelectAnyButton // Any mouse button (not just left) + // moves the selection to clicked cell ); TDbGridOptions = set of TDbGridOption; @@ -1014,6 +1015,11 @@ begin else Exclude(OldOptions, goHeaderPushedLook); + if dgCanSelectAnyButton in FOptions then + Include(OldOptions, goCanSelectAnyButton) + else + Exclude(OldOptions, goCanSelectAnyButton); + if (dgIndicator in ChangedOptions) then begin if (dgIndicator in FOptions) then FixedCols := FixedCols + 1 @@ -2226,7 +2232,7 @@ begin exit; end; - if button<>mbLeft then begin + if (button<>mbLeft) and not (dgCanSelectAnyButton in FOptions) then begin doInherited; exit; end; diff --git a/lcl/grids.pas b/lcl/grids.pas index 94a3e545eb..f98375bc07 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -104,7 +104,9 @@ type goHeaderPushedLook, // Header cells looks pushed when clicked goSelectionActive, // Setting grid.Selection moves also cell cursor goFixedColSizing, // Allow to resize fixed columns - goDontScrollPartCell // clicking partially visible cells will not scroll + goDontScrollPartCell, // clicking partially visible cells will not scroll + goCanSelectAnyButton // Not only left mouse button, but also right and + // middle buttons move selection to clicked cell ); TGridOptions = set of TGridOption; @@ -5718,7 +5720,8 @@ var begin inherited MouseDown(Button, Shift, X, Y); - if (csDesigning in componentState) or not (ssLeft in Shift) then + if (csDesigning in componentState) or + not ((goCanSelectAnyButton in FOptions) or (ssLeft in Shift)) then Exit; {$IfDef dbgGrid} DebugLn('MouseDown INIT'); {$Endif}