mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 17:29:31 +02:00
LCL: Don't trigger double-click on TreeView's fold-arrow if another node is selected. Issue #37051
git-svn-id: branches/fixes_2_0@63473 -
This commit is contained in:
parent
7e55431dc4
commit
824f8ec4a3
@ -3331,7 +3331,9 @@ type
|
|||||||
FLastVertScrollInfo: TScrollInfo;
|
FLastVertScrollInfo: TScrollInfo;
|
||||||
FMaxLvl: integer; // maximum level of all nodes
|
FMaxLvl: integer; // maximum level of all nodes
|
||||||
FMaxRight: integer; // maximum text width of all nodes (needed for horizontal scrolling)
|
FMaxRight: integer; // maximum text width of all nodes (needed for horizontal scrolling)
|
||||||
fMouseDownPos: TPoint;
|
FMouseDownPos: TPoint;
|
||||||
|
FMouseDownNodeSelected: Boolean;
|
||||||
|
FMouseDownOnFoldingSign: Boolean;
|
||||||
FMultiSelectStyle: TMultiSelectStyle;
|
FMultiSelectStyle: TMultiSelectStyle;
|
||||||
FHotTrackColor: TColor;
|
FHotTrackColor: TColor;
|
||||||
FOnAddition: TTVExpandedEvent;
|
FOnAddition: TTVExpandedEvent;
|
||||||
@ -3414,6 +3416,7 @@ type
|
|||||||
function IsStoredBackgroundColor: Boolean;
|
function IsStoredBackgroundColor: Boolean;
|
||||||
procedure HintMouseLeave(Sender: TObject);
|
procedure HintMouseLeave(Sender: TObject);
|
||||||
procedure ImageListChange(Sender: TObject);
|
procedure ImageListChange(Sender: TObject);
|
||||||
|
function MouseDownNode(X, Y: Integer): TTreeNode;
|
||||||
procedure OnChangeTimer(Sender: TObject);
|
procedure OnChangeTimer(Sender: TObject);
|
||||||
procedure SetAutoExpand(Value: Boolean);
|
procedure SetAutoExpand(Value: Boolean);
|
||||||
procedure SetBackgroundColor(Value: TColor);
|
procedure SetBackgroundColor(Value: TColor);
|
||||||
@ -3507,6 +3510,10 @@ type
|
|||||||
procedure Change(Node: TTreeNode); virtual;
|
procedure Change(Node: TTreeNode); virtual;
|
||||||
procedure Collapse(Node: TTreeNode); virtual;
|
procedure Collapse(Node: TTreeNode); virtual;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
|
procedure Click; override;
|
||||||
|
procedure DblClick; override;
|
||||||
|
procedure TripleClick; override;
|
||||||
|
procedure QuadClick; override;
|
||||||
procedure Delete(Node: TTreeNode); virtual;
|
procedure Delete(Node: TTreeNode); virtual;
|
||||||
procedure DestroyWnd; override;
|
procedure DestroyWnd; override;
|
||||||
procedure DoCreateNodeClass(var NewNodeClass: TTreeNodeClass); virtual;
|
procedure DoCreateNodeClass(var NewNodeClass: TTreeNodeClass); virtual;
|
||||||
|
@ -3310,6 +3310,30 @@ begin
|
|||||||
inherited CreateWnd;
|
inherited CreateWnd;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomTreeView.Click;
|
||||||
|
begin
|
||||||
|
if not FMouseDownOnFoldingSign then
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomTreeView.DblClick;
|
||||||
|
begin
|
||||||
|
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;
|
procedure TCustomTreeView.InitializeWnd;
|
||||||
begin
|
begin
|
||||||
inherited InitializeWnd;
|
inherited InitializeWnd;
|
||||||
@ -5534,23 +5558,27 @@ begin
|
|||||||
Result := FIndent >= 0;
|
Result := FIndent >= 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomTreeView.MouseDownNode(X, Y: Integer): TTreeNode;
|
||||||
|
begin
|
||||||
|
Result := GetNodeAt(X, Y);
|
||||||
|
// Update the NodeSelected flag.
|
||||||
|
FMouseDownNodeSelected := Assigned(Result) and
|
||||||
|
(Result.Selected or ((tvoAllowMultiselect in Options) and Result.MultiSelected));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomTreeView.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
procedure TCustomTreeView.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
var
|
var
|
||||||
CursorNode: TTreeNode;
|
CursorNode: TTreeNode;
|
||||||
LogicalX: Integer;
|
LogicalX: Integer;
|
||||||
CursorNodeSelected: Boolean;
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseDrag}
|
{$IFDEF VerboseDrag}
|
||||||
DebugLn('TCustomTreeView.MouseDown A ',DbgSName(Self),' ');
|
DebugLn('TCustomTreeView.MouseDown A ',DbgSName(Self),' ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
fMouseDownPos := Point(X,Y);
|
FMouseDownPos := Point(X,Y);
|
||||||
FStates:=FStates-[tvsEditOnMouseUp,tvsSingleSelectOnMouseUp];
|
FStates:=FStates-[tvsEditOnMouseUp,tvsSingleSelectOnMouseUp];
|
||||||
|
|
||||||
CursorNode := GetNodeAt(X, Y);
|
CursorNode := MouseDownNode(X, Y);
|
||||||
CursorNodeSelected := (CursorNode<>nil)
|
|
||||||
and (CursorNode.Selected
|
|
||||||
or ((tvoAllowMultiselect in Options) and CursorNode.MultiSelected));
|
|
||||||
LogicalX:=X;
|
LogicalX:=X;
|
||||||
|
|
||||||
//change selection on right click
|
//change selection on right click
|
||||||
@ -5564,7 +5592,7 @@ begin
|
|||||||
if not (tvoAllowMultiselect in Options) then
|
if not (tvoAllowMultiselect in Options) then
|
||||||
Selected := CursorNode
|
Selected := CursorNode
|
||||||
else
|
else
|
||||||
if not CursorNodeSelected then
|
if not FMouseDownNodeSelected then
|
||||||
Items.SelectOnlyThis(CursorNode);
|
Items.SelectOnlyThis(CursorNode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5574,27 +5602,25 @@ begin
|
|||||||
inherited MouseDown(Button, Shift, X, Y);
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
|
|
||||||
//CursorNode must be reassigned again - e.g. in OnMouseDown the node can be deleted or moved.
|
//CursorNode must be reassigned again - e.g. in OnMouseDown the node can be deleted or moved.
|
||||||
CursorNode := GetNodeAt(X, Y);
|
CursorNode := MouseDownNode(X, Y);
|
||||||
CursorNodeSelected := (CursorNode<>nil)
|
|
||||||
and (CursorNode.Selected
|
//Flag is used for DblClick/TripleClick/QuadClick, so set it before testing ShiftState
|
||||||
or ((tvoAllowMultiselect in Options) and CursorNode.MultiSelected));
|
FMouseDownOnFoldingSign :=
|
||||||
|
Assigned(CursorNode) and CursorNode.HasChildren and ShowButtons and
|
||||||
|
(LogicalX >= CursorNode.DisplayExpandSignLeft) and
|
||||||
|
(LogicalX < CursorNode.DisplayExpandSignRight);
|
||||||
|
|
||||||
//change selection on left click
|
//change selection on left click
|
||||||
if (Button = mbLeft) and//left click
|
if (Button = mbLeft) and//left click
|
||||||
(([ssDouble, ssTriple, ssQuad] * Shift) = []) and//single or first of a multi click
|
(([ssDouble, ssTriple, ssQuad] * Shift) = []) and//single or first of a multi click
|
||||||
(CursorNode <> nil) then
|
(CursorNode <> nil) then
|
||||||
begin
|
begin
|
||||||
if CursorNode.HasChildren and ShowButtons and
|
if FMouseDownOnFoldingSign then
|
||||||
(LogicalX >= CursorNode.DisplayExpandSignLeft) and
|
|
||||||
(LogicalX < CursorNode.DisplayExpandSignRight) then
|
|
||||||
begin
|
|
||||||
// mousedown occured on expand sign -> expand/collapse
|
// mousedown occured on expand sign -> expand/collapse
|
||||||
CursorNode.Expanded := not CursorNode.Expanded;
|
CursorNode.Expanded := not CursorNode.Expanded
|
||||||
end
|
|
||||||
else if LogicalX >= CursorNode.DisplayStateIconLeft then
|
else if LogicalX >= CursorNode.DisplayStateIconLeft then
|
||||||
begin
|
begin
|
||||||
// mousedown occured in text or icon
|
// mousedown occured in text or icon -> select node and begin drag operation
|
||||||
// -> select node and begin drag operation
|
|
||||||
{$IFDEF VerboseDrag}
|
{$IFDEF VerboseDrag}
|
||||||
DebugLn(['TCustomTreeView.MouseDown In Text ',DbgSName(Self),' MouseCapture=',MouseCapture]);
|
DebugLn(['TCustomTreeView.MouseDown In Text ',DbgSName(Self),' MouseCapture=',MouseCapture]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -5623,7 +5649,7 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if not CursorNodeSelected then
|
if not FMouseDownNodeSelected then
|
||||||
Items.SelectOnlyThis(CursorNode)
|
Items.SelectOnlyThis(CursorNode)
|
||||||
else
|
else
|
||||||
Include(FStates, tvsSingleSelectOnMouseUp);
|
Include(FStates, tvsSingleSelectOnMouseUp);
|
||||||
@ -5664,27 +5690,29 @@ procedure TCustomTreeView.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
|||||||
var
|
var
|
||||||
aMouseDownNode, aMouseUpNode: TTreeNode;
|
aMouseDownNode, aMouseUpNode: TTreeNode;
|
||||||
begin
|
begin
|
||||||
if (FHintWnd<>nil) and FHintWnd.Visible then // must hide hint window in mouse up to receive redirected mouse up messages
|
// must hide hint window in mouse up to receive redirected mouse up messages
|
||||||
|
if (FHintWnd<>nil) and FHintWnd.Visible then
|
||||||
FHintWnd.Hide;
|
FHintWnd.Hide;
|
||||||
inherited MouseUp(Button, Shift, X, Y);
|
inherited MouseUp(Button, Shift, X, Y);
|
||||||
if (Button = mbRight) and (Shift = [ssRight]) and Assigned(PopupMenu) then
|
if (Button = mbRight) and (Shift = [ssRight]) and Assigned(PopupMenu) then
|
||||||
exit;
|
exit;
|
||||||
if Button=mbLeft then
|
if Button=mbLeft then
|
||||||
|
begin
|
||||||
MouseCapture := False;
|
MouseCapture := False;
|
||||||
if (Button=mbLeft)
|
if FStates * [tvsDblClicked, tvsTripleClicked, tvsQuadClicked] = [] then
|
||||||
and (FStates * [tvsDblClicked, tvsTripleClicked, tvsQuadClicked] = [])
|
|
||||||
then begin
|
|
||||||
//AquirePrimarySelection;
|
|
||||||
aMouseDownNode:=GetNodeAt(fMouseDownPos.X,fMouseDownPos.Y);
|
|
||||||
aMouseUpNode:=GetNodeAt(X,Y);
|
|
||||||
if (abs(fMouseDownPos.X-X)+abs(fMouseDownPos.Y-Y)<10)
|
|
||||||
and (aMouseDownNode=aMouseUpNode) then
|
|
||||||
begin
|
begin
|
||||||
// mouse up on mouse-down node
|
//AquirePrimarySelection;
|
||||||
if (tvsEditOnMouseUp in FStates) and (not ReadOnly) then
|
aMouseDownNode:=GetNodeAt(FMouseDownPos.X,FMouseDownPos.Y);
|
||||||
BeginEditing(Selected)
|
aMouseUpNode:=GetNodeAt(X,Y);
|
||||||
else if (tvsSingleSelectOnMouseUp in FStates) then
|
if (abs(FMouseDownPos.X-X)+abs(FMouseDownPos.Y-Y)<10)
|
||||||
Items.SelectOnlyThis(aMouseUpNode);
|
and (aMouseDownNode=aMouseUpNode) then
|
||||||
|
begin
|
||||||
|
// mouse up on mouse-down node
|
||||||
|
if (tvsEditOnMouseUp in FStates) and (not ReadOnly) then
|
||||||
|
BeginEditing(Selected)
|
||||||
|
else if (tvsSingleSelectOnMouseUp in FStates) then
|
||||||
|
Items.SelectOnlyThis(aMouseUpNode);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
FStates:=FStates-[tvsDblClicked,tvsTripleClicked,tvsQuadClicked,
|
FStates:=FStates-[tvsDblClicked,tvsTripleClicked,tvsQuadClicked,
|
||||||
|
Loading…
Reference in New Issue
Block a user