View Issue Details

IDProjectCategoryView StatusLast Update
0018344LazarusLCLpublic2013-01-03 13:13
ReporterTomasz WieckowskiAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.31 (SVN)Product Build 
Target Version1.0.2Fixed in Version1.1 (SVN) 
Summary0018344: [Patch] TStringGrid - unexpected selection
DescriptionWhen you get MessageBox OnEditingDone, OnValidateEntry then you will get unexpected selection.
I see this behavior on Win,GTK2.
Steps To Reproduce1.Compile and Run attached project.
2.Put some text to cell and then (don't press enter) click on other cell. MessageDlg will appears
3.When you click OK on MessageDlg then you will see unexpected selection.
TagsNo tags attached.
Fixed in Revision39011
LazTarget1.0.2
WidgetsetGTK 2, Win32/Win64
Attached Files
  • StringGrid-Select.zip (3,066 bytes)
  • grids_validate.patch (438 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 29006)
    +++ lcl/grids.pas	(working copy)
    @@ -6629,11 +6629,10 @@
         except
           on E:Exception do begin
             result := false;
    -        if FGridState=gsSelecting then
    -          FGridState := gsNormal;
             Application.HandleException(E);
           end;
         end;
    +    FGridState := gsNormal;
       end;
     end;
     
    
    grids_validate.patch (438 bytes)
  • grids.selectionbug.diff (427 bytes)
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 37598)
    +++ lcl/grids.pas	(working copy)
    @@ -7281,6 +7281,7 @@
         and Editor.Visible then
       begin
         FEditorMode:=False;
    +    FGridState := gsNormal;
         {$ifdef dbgGrid}DebugLn('EditorHide [',Editor.ClassName,'] INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$endif}
         LockEditor;
         try
    

Relationships

has duplicate 0012226 resolvedBart Broersma DrawGrid/StringGrid with PopupMenu problem, when using Ctrl key and showing form 

Activities

2010-12-30 09:35

 

StringGrid-Select.zip (3,066 bytes)

Gerard V

2010-12-30 10:13

reporter   ~0044702

If I click into a cell, type some text and then click into another cell, thats what happens:
- OnEditingDone is fired
- On ValidateEntry is Fired
- The mouse starts behaving as if it was selecting a group of cells. When I move the mouse above the grid, it follows selecting a group of cells.
This is clearly wrong.
Aside this problem, I found another one:
If I type text in a cell and press Enter, only ValidateEntry is fired, not OnEditingDone. Then the cursor is not visible. If I press Enter another time, the cursor moves to the next cell on the right, and OnEditingDone is fired. If I click immediatly in another cell, both events are fired.
GTK2, Linux.

2011-01-14 17:33

 

grids_validate.patch (438 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 29006)
+++ lcl/grids.pas	(working copy)
@@ -6629,11 +6629,10 @@
     except
       on E:Exception do begin
         result := false;
-        if FGridState=gsSelecting then
-          FGridState := gsNormal;
         Application.HandleException(E);
       end;
     end;
+    FGridState := gsNormal;
   end;
 end;
 
grids_validate.patch (438 bytes)

Tomasz Wieckowski

2011-01-14 17:33

reporter   ~0045180

Patch uploaded for fix the bug.

Jesus Reyes

2011-02-16 22:00

developer   ~0046101

The proposed patch doesn't look right as it depends on OnValidateEntry handler to be defined, the same it seems, can be achieved by accessing protected property FGridState in OnValidateEntry and change it manually to gsNormal.

This is a tricky bug, the real problem is that if the grid detects a MouseDown it would expect also a MouseUp (there is where selection is cancelled). But as demostrated by the sample project, MouseUp may never arrive and the grid is left in an incomplete state.

It needs another round.

Felipe Monteiro de Carvalho

2011-09-28 15:40

developer   ~0052254

The patch was rejected, so retargeting to 1.0 to make it possible to release 0.99

Vincent Snijders

2012-03-06 07:40

manager   ~0057305

Last year, I set LazTarget 0.99, because I saw an inconsistency with Target Version and undid (unwantingly) revert Felipe's change.

Target 1.0 for now, but if Jesus doesn't find a fix, postpone to 1.2.

2012-06-28 18:51

 

grids.selectionbug.diff (427 bytes)
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 37598)
+++ lcl/grids.pas	(working copy)
@@ -7281,6 +7281,7 @@
     and Editor.Visible then
   begin
     FEditorMode:=False;
+    FGridState := gsNormal;
     {$ifdef dbgGrid}DebugLn('EditorHide [',Editor.ClassName,'] INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$endif}
     LockEditor;
     try

Bart Broersma

2012-06-28 18:53

developer   ~0060704

Possible fix attached.
Not sure if this is OK, so I won't commit it myself but offer it for review.

samuel herzog

2012-07-16 20:47

developer   ~0061091

Last edited: 2012-07-16 20:48

I applied the patch (from Bart) locally and tested today with version Lazarus 1.1 r37649 FPC 2.6.1 i386-win32-win32/win64.

The patch fixes the problem.

samuel herzog

2012-07-18 20:54

developer   ~0061129

I tested today the patch from Bart with Lazarus 1.1 r37964M FPC 2.4.4 i386-linux-gtk 2. Looks fine.

So please someone add the patch and close this issue.

Bart Broersma

2012-07-23 11:35

developer   ~0061189

Soem devel with inner knowledge of Grids should take a look.
I feel uncomfortable committing htis patch myself, it lookt too much a hack.

Jesus Reyes

2012-10-09 08:55

developer   ~0063018

I applied Bart's patch.
Thanks.

Issue History

Date Modified Username Field Change
2010-12-30 09:35 Tomasz Wieckowski New Issue
2010-12-30 09:35 Tomasz Wieckowski File Added: StringGrid-Select.zip
2010-12-30 09:35 Tomasz Wieckowski Widgetset => GTK 2, Win32/Win64
2010-12-30 09:56 Vincent Snijders LazTarget => 1.0
2010-12-30 09:56 Vincent Snijders Assigned To => Jesus Reyes
2010-12-30 09:56 Vincent Snijders Status new => assigned
2010-12-30 09:56 Vincent Snijders Target Version => 1.0.0
2010-12-30 10:13 Gerard V Note Added: 0044702
2011-01-14 17:33 Tomasz Wieckowski File Added: grids_validate.patch
2011-01-14 17:33 Tomasz Wieckowski Note Added: 0045180
2011-02-16 22:00 Jesus Reyes Note Added: 0046101
2011-04-04 05:35 Paul Ishenin LazTarget 1.0 => 0.99.0
2011-04-04 05:38 Paul Ishenin Target Version 1.0.0 => 0.99.0
2011-09-28 15:40 Felipe Monteiro de Carvalho LazTarget 0.99.0 => 1.0
2011-09-28 15:40 Felipe Monteiro de Carvalho Note Added: 0052254
2011-10-28 10:06 Vincent Snijders LazTarget 1.0 => 0.99.0
2012-03-06 07:40 Vincent Snijders LazTarget 0.99.0 => 1.0
2012-03-06 07:40 Vincent Snijders Note Added: 0057305
2012-03-06 07:40 Vincent Snijders Target Version 0.99.0 => 1.0.0
2012-06-28 18:51 Bart Broersma File Added: grids.selectionbug.diff
2012-06-28 18:53 Bart Broersma Note Added: 0060704
2012-07-16 20:47 samuel herzog Note Added: 0061091
2012-07-16 20:48 samuel herzog Note Edited: 0061091
2012-07-18 20:54 samuel herzog Note Added: 0061129
2012-07-22 10:40 samuel herzog Status assigned => confirmed
2012-07-22 10:40 samuel herzog Summary TStringGrid - unexpected selection => [Patch] TStringGrid - unexpected selection
2012-07-23 11:35 Bart Broersma Note Added: 0061189
2012-08-30 12:22 Vincent Snijders Target Version 1.0.0 => 1.0.2
2012-08-30 12:22 Vincent Snijders LazTarget 1.0 => 1.0.2
2012-10-09 08:55 Jesus Reyes Fixed in Revision => 39011
2012-10-09 08:55 Jesus Reyes Status confirmed => resolved
2012-10-09 08:55 Jesus Reyes Fixed in Version => 1.1 (SVN)
2012-10-09 08:55 Jesus Reyes Resolution open => fixed
2012-10-09 08:55 Jesus Reyes Note Added: 0063018
2012-11-09 23:45 Bart Broersma Relationship added has duplicate 0012226
2013-01-03 13:13 Tomasz Wieckowski Status resolved => closed