View Issue Details

IDProjectCategoryView StatusLast Update
0037051LazarusLCLpublic2020-05-16 10:26
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionreopened 
PlatformUbuntu 20 x64, Win10 x64 
Product Version2.1 (SVN) 
Summary0037051: TreeView: double-click on tree fold-arrow produces double-click event over the selected node
Descriptionissue is shown in CudaText here with youtube video:
http://synwrite.sourceforge.net/forums/viewtopic.php?f=5&t=2470

Steps To ReproduceI repeated the same in IDE in Project Inspector

- in Files tree node, dbl-click some file to open it in source editor
- close source editor tab by X
- dbl-click in Project Inspector the tree fold-arrow near "Files"
--> the same file opens again
TagsNo tags attached.
Fixed in Revisionr63139, r63147, r63171
LazTarget-
WidgetsetGTK 2, Win32/Win64
Attached Files

Activities

Juha Manninen

2020-05-12 20:53

developer   ~0122742

Fixed, please test.

CudaText man

2020-05-13 09:53

reporter   ~0122759

not fully resolved - resolved for OnDblClick but the same issue is here with OnClick.
ie, in CudaText user clicks the fold-arrow -> Treeview gets OnClick -> file opens again.

Juha Manninen

2020-05-14 00:30

developer   ~0122777

Ok, I did the same thing for Click event. Please test.

CudaText man

2020-05-14 06:33

reporter   ~0122779

click on fold-arrow is fixed.
I see new issue after this fix.
before: single click in CudaText on unselected node - that file opens (OnClick works).
now: single click on unselected node - that node is just selected but file is not opened (OnClick don't work). single click on SELECTED node - file is opened (OnClick works).

Juha Manninen

2020-05-15 23:22

developer   ~0122826

Yes, the code is wrong. OnClick should not be triggered when the expand arrow is clicked.
CudaText man, where in the code is the arrow dealt with? You could also study the TreeView code. I try to find time for this during the weekend, too.

CudaText man

2020-05-16 08:16

reporter   ~0122841

fix attached. it works for Click/DblClick/TripleClick/QuadClick.
tr.diff (3,026 bytes)   
Index: lcl/comctrls.pp
===================================================================
--- lcl/comctrls.pp	(revision 63170)
+++ lcl/comctrls.pp	(working copy)
@@ -3341,6 +3341,7 @@
     FMaxRight: integer; // maximum text width of all nodes (needed for horizontal scrolling)
     FMouseDownPos: TPoint;
     FMouseDownNodeSelected: Boolean;
+    FMouseDownOnFoldingSign: Boolean;
     FMultiSelectStyle: TMultiSelectStyle;
     FHotTrackColor: TColor;
     FDisabledFontColor: TColor;
@@ -3520,8 +3521,8 @@
     procedure CreateWnd; override;
     procedure Click; override;
     procedure DblClick; override;
-    //procedure TripleClick; override;  - Are these needed?
-    //procedure QuadClick; override;
+    procedure TripleClick; override;
+    procedure QuadClick; override;
     procedure Delete(Node: TTreeNode); virtual;
     procedure DestroyWnd; override;
     procedure DoCreateNodeClass(var NewNodeClass: TTreeNodeClass); virtual;
Index: lcl/include/treeview.inc
===================================================================
--- lcl/include/treeview.inc	(revision 63170)
+++ lcl/include/treeview.inc	(working copy)
@@ -3317,16 +3317,28 @@
 
 procedure TCustomTreeView.Click;
 begin
-  if FMouseDownNodeSelected then
+  if not FMouseDownOnFoldingSign then
     inherited;
 end;
 
 procedure TCustomTreeView.DblClick;
 begin
-  if FMouseDownNodeSelected then
+  if not FMouseDownOnFoldingSign then
     inherited;
 end;
 
+procedure TCustomTreeView.TripleClick;
+begin
+  if not FMouseDownOnFoldingSign then
+    inherited;
+end;
+
+procedure TCustomTreeView.QuadClick;
+begin
+  if not FMouseDownOnFoldingSign then
+    inherited;
+end;
+
 procedure TCustomTreeView.InitializeWnd;
 begin
   inherited InitializeWnd;
@@ -5580,6 +5592,7 @@
   DebugLn('TCustomTreeView.MouseDown A ',DbgSName(Self),' ');
   {$ENDIF}
   FMouseDownPos := Point(X,Y);
+  FMouseDownOnFoldingSign := False;
   FStates:=FStates-[tvsEditOnMouseUp,tvsSingleSelectOnMouseUp];
 
   CursorNode := MouseDownNode(X, Y);
@@ -5608,14 +5621,20 @@
   //CursorNode must be reassigned again - e.g. in OnMouseDown the node can be deleted or moved.
   CursorNode := MouseDownNode(X, Y);
 
+  //Flag is used for DblClick/TripleClick/QuadClick, so set it before testing ShiftState
+  FMouseDownOnFoldingSign :=
+    (CursorNode <> nil) and
+    CursorNode.HasChildren and
+    ShowButtons and
+    (LogicalX >= CursorNode.DisplayExpandSignLeft) and
+    (LogicalX < CursorNode.DisplayExpandSignRight);
+
   //change selection on left click
   if (Button = mbLeft) and//left click
      (([ssDouble, ssTriple, ssQuad] * Shift) = []) and//single or first of a multi click
      (CursorNode <> nil) then
   begin
-    if CursorNode.HasChildren and ShowButtons and
-       (LogicalX >= CursorNode.DisplayExpandSignLeft) and
-       (LogicalX < CursorNode.DisplayExpandSignRight) then
+    if FMouseDownOnFoldingSign then
     begin
       // mousedown occured on expand sign -> expand/collapse
       CursorNode.Expanded := not CursorNode.Expanded;
tr.diff (3,026 bytes)   

Juha Manninen

2020-05-16 10:26

developer   ~0122844

Damn right, it was the Node's DisplayExpandSignLeft and DisplayExpandSignRight methods. Somehow I missed them earlier. I should be more careful.
Good catch CudaText man. Thanks.

Issue History

Date Modified Username Field Change
2020-05-11 19:00 CudaText man New Issue
2020-05-12 20:07 Juha Manninen Assigned To => Juha Manninen
2020-05-12 20:07 Juha Manninen Status new => assigned
2020-05-12 20:53 Juha Manninen Status assigned => resolved
2020-05-12 20:53 Juha Manninen Resolution open => fixed
2020-05-12 20:53 Juha Manninen Fixed in Revision => r63139
2020-05-12 20:53 Juha Manninen LazTarget => -
2020-05-12 20:53 Juha Manninen Widgetset GTK 2, Win32/Win64 => GTK 2, Win32/Win64
2020-05-12 20:53 Juha Manninen Note Added: 0122742
2020-05-13 09:53 CudaText man Note Added: 0122759
2020-05-13 09:54 CudaText man Status resolved => assigned
2020-05-13 09:54 CudaText man Resolution fixed => reopened
2020-05-14 00:30 Juha Manninen Status assigned => resolved
2020-05-14 00:30 Juha Manninen Fixed in Revision r63139 => r63139, r63147
2020-05-14 00:30 Juha Manninen Widgetset GTK 2, Win32/Win64 => GTK 2, Win32/Win64
2020-05-14 00:30 Juha Manninen Note Added: 0122777
2020-05-14 06:33 CudaText man Status resolved => assigned
2020-05-14 06:33 CudaText man Note Added: 0122779
2020-05-15 23:22 Juha Manninen Note Added: 0122826
2020-05-16 08:16 CudaText man Note Added: 0122841
2020-05-16 08:16 CudaText man File Added: tr.diff
2020-05-16 10:26 Juha Manninen Status assigned => resolved
2020-05-16 10:26 Juha Manninen Fixed in Revision r63139, r63147 => r63139, r63147, r63171
2020-05-16 10:26 Juha Manninen Widgetset GTK 2, Win32/Win64 => GTK 2, Win32/Win64
2020-05-16 10:26 Juha Manninen Note Added: 0122844