Commit 257f95ec authored by Juha Manninen's avatar Juha Manninen
Browse files

LCL: Never trigger click events on TreeView's fold-arrow. Issue #37051, patch from CudaText man.

git-svn-id: trunk@63171 -
parent 5b86ef8e
......@@ -3341,6 +3341,7 @@ type
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 @@ type
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;
......
......@@ -3317,13 +3317,25 @@ end;
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;
......@@ -5566,7 +5578,7 @@ function TCustomTreeView.MouseDownNode(X, Y: Integer): TTreeNode;
begin
Result := GetNodeAt(X, Y);
// Update the NodeSelected flag.
FMouseDownNodeSelected := (Result<>nil) and
FMouseDownNodeSelected := Assigned(Result) and
(Result.Selected or ((tvoAllowMultiselect in Options) and Result.MultiSelected));
end;
......@@ -5608,18 +5620,20 @@ begin
//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 :=
Assigned(CursorNode) 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
begin
if FMouseDownOnFoldingSign then
// mousedown occured on expand sign -> expand/collapse
CursorNode.Expanded := not CursorNode.Expanded;
end
CursorNode.Expanded := not CursorNode.Expanded
else if LogicalX >= CursorNode.DisplayStateIconLeft then
begin
// mousedown occured in text or icon -> select node and begin drag operation
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment