View Issue Details

IDProjectCategoryView StatusLast Update
0014619LazarusLCLpublic2009-09-26 13:29
ReporterTomasz Wieckowski Assigned ToJesus Reyes  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0014619: TStringGrid MouseToCell -fix
DescriptionThe MouseToCell function should return -1 when mouse is out of the cells (not last col/row when mouse is on free space "when cells don't fill all stringgrid area").

I attached patch that should fix this problem.
TagsNo tags attached.
Fixed in Revision21870
LazTarget0.9.30
WidgetsetGTK 2, Win32/Win64
Attached Files

Activities

2009-09-18 12:41

 

mousetocell.patch (1,248 bytes)   
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(wersja 21759)
+++ lcl/grids.pas	(kopia robocza)
@@ -4633,7 +4633,7 @@
         if (Index>=0) and (Index<ColCount) then
           Offset:=Offset-FixedWidth+integer(PtrUInt(AccumWidth[Index]))+TLColOff;
         if (Index<0) or (Index>=ColCount) or (Offset>GridWidth-1) then begin
-          Index := ColCount-1;
+          Index :=-1;
           exit;
         end;
       end;
@@ -4652,7 +4652,7 @@
         if (Index>=0) and (Index<RowCount) then
           Offset:=Offset-FixedHeight+integer(PtrUInt(AccumHeight[Index]))+TLRowOff;
         if (Index<0) or (Index>=RowCount) or (Offset>GridHeight-1) then begin
-          Index:=RowCount-1;
+          Index:=-1;
           Exit; // Out of Range
         end;
       end;
@@ -5705,7 +5705,14 @@
 begin
   // Do not raise Exception if out of range
   OffsetToColRow(True, True, X, ACol, dummy);
-  OffsetToColRow(False,True, Y, ARow, dummy);
+  if ACol = -1 then begin
+    ARow:=-1;
+    exit;
+  end else begin
+    OffsetToColRow(False,True, Y, ARow, dummy);
+    if ARow = -1 then
+      ACol:=-1;
+  end;
 end;
 
 { Convert a fisical Mouse coordinate into a logical cell coordinate }
mousetocell.patch (1,248 bytes)   

Tomasz Wieckowski

2009-09-25 11:24

reporter   ~0030969

It would be nice if this problem will be fixed in 0.9.28.
In my case, malfunction of MouseToCell seriously hampers the work of the program. I think that it is not too difficult.

Vincent Snijders

2009-09-25 11:29

manager   ~0030970

Last edited: 2009-09-25 11:29

But waiting for testing this fix might delay 0.9.28 another week, so adding it is unlikely.

Jesus Reyes

2009-09-25 18:39

developer   ~0030975

Last edited: 2009-09-25 18:39

This is not a bug but a feature as such there might have unexpected consequences if I simply apply the patch.

This issue is related to AllowOutboundsEvents grid's property, see http://wiki.lazarus.freepascal.org/Grids_Reference_Page#property_AllowOutboundEvents:boolean.3B added to gain some delphi compatibility, if the patch is modified so the new code is wrapped inside "if not AllowOutboundsEvents then .. " I don't see a problem to even merge it to 0.9.28

Tomasz Wieckowski

2009-09-25 20:40

reporter   ~0030979

Yes, you're right, the code should work only in delphi compatibility (AllowOutboundEvents=false).

Issue History

Date Modified Username Field Change
2009-09-18 12:41 Tomasz Wieckowski New Issue
2009-09-18 12:41 Tomasz Wieckowski File Added: mousetocell.patch
2009-09-18 12:41 Tomasz Wieckowski Widgetset => GTK 2, Win32/Win64
2009-09-18 12:50 Vincent Snijders LazTarget => 0.9.30
2009-09-18 12:50 Vincent Snijders Assigned To => Jesus Reyes
2009-09-18 12:50 Vincent Snijders Status new => assigned
2009-09-18 12:50 Vincent Snijders Target Version => 0.9.30
2009-09-25 11:24 Tomasz Wieckowski Note Added: 0030969
2009-09-25 11:29 Vincent Snijders Note Added: 0030970
2009-09-25 11:29 Vincent Snijders Note Edited: 0030970
2009-09-25 18:39 Jesus Reyes Note Added: 0030975
2009-09-25 18:39 Jesus Reyes Note Edited: 0030975
2009-09-25 20:40 Tomasz Wieckowski Note Added: 0030979
2009-09-25 21:32 Jesus Reyes Fixed in Revision => 21870
2009-09-25 21:32 Jesus Reyes Status assigned => resolved
2009-09-25 21:32 Jesus Reyes Fixed in Version => 0.9.29 (SVN)
2009-09-25 21:32 Jesus Reyes Resolution open => fixed
2009-09-26 13:29 Tomasz Wieckowski Status resolved => closed