Hi,

Attached is a patch for the grids.pas unit.  Compared to the Delphi
grids, the TCustomGrid.Click event under Lazarus fired way to little.
This patch fixes that.

Fixes:
--------------
 * Click event fires when Col property is set
 * Click event fires when Row property is set
 * Click event fires when navigation keys (left, right, up, down,
PgUp, PgDn, Begin, End) are pressed.


Outstanding problems after this patch is applied (I should create
Mantis reports for these).
--------------------------------------
* Click event fires whev navigation keys are pressed, but the
selection doesn't (can't) change. Like pressing the up arrow while the
selection is already in the top/left corner. Click shouldn't fire in
this case.
* Click fires twice when selecting a range (not sure why)
* On loosing focus in a TStringGrid, it doesn't show the last
selected cell. Compared to Delphi the cell's background should be
painted with the selection color (but no focus rectangle).


--
Graeme Geldenhuys

There's no place like S34° 03.168'  E018° 49.342'
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 10971)
+++ lcl/grids.pas	(working copy)
@@ -2006,12 +2006,14 @@
 begin
   if AValue=FCol then Exit;
   MoveExtend(False, AValue, FRow);
+  Click;
 end;
 
 procedure TCustomGrid.SetRow(AValue: Integer);
 begin
   if AValue=FRow then Exit;
   MoveExtend(False, FCol, AValue);
+  Click;
 end;
 
 procedure TCustomGrid.Sort(ColSorting: Boolean; index, IndxFrom, IndxTo: Integer);
@@ -4328,7 +4330,10 @@
     gsSelecting:
       begin
         if SelectActive then
-          MoveExtend(False, Cur.x, Cur.y)
+        begin
+          MoveExtend(False, Cur.x, Cur.y);
+          Click;
+        end
         else
           CellClick(cur.x, cur.y);
       end;
@@ -4640,6 +4645,7 @@
     SelectActive:=Sh;
     MoveNextSelectable(Rel, aCol, aRow);
     Key:=0;
+    Click;
   end;
 begin
   {$ifdef dbgGrid}DebugLn('Grid.KeyDown INIT Key=',IntToStr(Key));{$endif}

Reply via email to