mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:17:18 +02:00
LCL: Select a single TreeView node with RightClick also when MultiSelect is enabled. Issue #28193, patch from Ondrej Pokorny.
git-svn-id: trunk@49227 -
This commit is contained in:
parent
c6b6503cf2
commit
ff08bf968d
@ -5192,17 +5192,55 @@ var
|
|||||||
CursorNode: TTreeNode;
|
CursorNode: TTreeNode;
|
||||||
LogicalX: Integer;
|
LogicalX: Integer;
|
||||||
CursorNodeSelected: Boolean;
|
CursorNodeSelected: Boolean;
|
||||||
|
|
||||||
procedure ChangeSelection;
|
|
||||||
begin
|
begin
|
||||||
if (CursorNode <> nil) then
|
{$IFDEF VerboseDrag}
|
||||||
|
DebugLn('TCustomTreeView.MouseDown A ',DbgSName(Self),' ');
|
||||||
|
{$ENDIF}
|
||||||
|
fMouseDownPos := Point(X,Y);
|
||||||
|
FStates:=FStates-[tvsEditOnMouseUp,tvsSingleSelectOnMouseUp];
|
||||||
|
|
||||||
|
CursorNode := GetNodeAt(X, Y);
|
||||||
|
CursorNodeSelected := (CursorNode<>nil)
|
||||||
|
and (CursorNode.Selected
|
||||||
|
or ((tvoAllowMultiselect in Options) and CursorNode.MultiSelected));
|
||||||
|
LogicalX:=X;
|
||||||
|
|
||||||
|
//change selection on right click
|
||||||
|
if (Button = mbRight) and RightClickSelect and//right click
|
||||||
|
(([ssDouble, ssTriple, ssQuad] * Shift) = []) and//single or first of a multi click
|
||||||
|
not(ssCtrl in Shift) and//only when CTRL is not pressed
|
||||||
|
(CursorNode <> nil) and
|
||||||
|
(LogicalX >= CursorNode.DisplayStateIconLeft)//only after expand sign
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
if not (tvoAllowMultiselect in Options) then
|
||||||
|
Selected := CursorNode
|
||||||
|
else
|
||||||
|
if not CursorNodeSelected then
|
||||||
|
Items.SelectOnlyThis(CursorNode);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not Focused and CanFocus then
|
||||||
|
SetFocus;
|
||||||
|
|
||||||
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
|
|
||||||
|
//CursorNode must be reassigned again - e.g. in OnMouseDown the node can be deleted or moved.
|
||||||
|
CursorNode := GetNodeAt(X, Y);
|
||||||
|
CursorNodeSelected := (CursorNode<>nil)
|
||||||
|
and (CursorNode.Selected
|
||||||
|
or ((tvoAllowMultiselect in Options) and CursorNode.MultiSelected));
|
||||||
|
|
||||||
|
//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
|
begin
|
||||||
if CursorNode.HasChildren and ShowButtons and
|
if CursorNode.HasChildren and ShowButtons and
|
||||||
(LogicalX >= CursorNode.DisplayExpandSignLeft) and
|
(LogicalX >= CursorNode.DisplayExpandSignLeft) and
|
||||||
(LogicalX < CursorNode.DisplayExpandSignRight) then
|
(LogicalX < CursorNode.DisplayExpandSignRight) then
|
||||||
begin
|
begin
|
||||||
// mousedown occured on expand sign -> expand/collapse only on left button
|
// mousedown occured on expand sign -> expand/collapse
|
||||||
if (Button = mbLeft) then
|
|
||||||
CursorNode.Expanded := not CursorNode.Expanded;
|
CursorNode.Expanded := not CursorNode.Expanded;
|
||||||
end
|
end
|
||||||
else if LogicalX >= CursorNode.DisplayStateIconLeft then
|
else if LogicalX >= CursorNode.DisplayStateIconLeft then
|
||||||
@ -5229,8 +5267,7 @@ var
|
|||||||
UnlockSelectionChangeEvent;
|
UnlockSelectionChangeEvent;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else if (ssCtrl in Shift) then
|
||||||
if (ssCtrl in Shift) then
|
|
||||||
begin
|
begin
|
||||||
Exclude(FStates,tvsEditOnMouseUp);
|
Exclude(FStates,tvsEditOnMouseUp);
|
||||||
CursorNode.MultiSelected:=not CursorNode.MultiSelected;
|
CursorNode.MultiSelected:=not CursorNode.MultiSelected;
|
||||||
@ -5239,43 +5276,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if not CursorNodeSelected then
|
if not CursorNodeSelected then
|
||||||
Items.SelectOnlyThis(CursorNode)
|
Items.SelectOnlyThis(CursorNode)
|
||||||
else if Button = mbLeft then
|
else
|
||||||
Include(FStates, tvsSingleSelectOnMouseUp);
|
Include(FStates, tvsSingleSelectOnMouseUp);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end
|
||||||
end;//ChangeSelection
|
else// multi click
|
||||||
|
|
||||||
begin
|
|
||||||
{$IFDEF VerboseDrag}
|
|
||||||
DebugLn('TCustomTreeView.MouseDown A ',DbgSName(Self),' ');
|
|
||||||
{$ENDIF}
|
|
||||||
fMouseDownPos := Point(X,Y);
|
|
||||||
FStates:=FStates-[tvsEditOnMouseUp,tvsSingleSelectOnMouseUp];
|
|
||||||
|
|
||||||
if not Focused and CanFocus then
|
|
||||||
SetFocus;
|
|
||||||
|
|
||||||
CursorNode := GetNodeAt(X, Y);
|
|
||||||
CursorNodeSelected := (CursorNode<>nil)
|
|
||||||
and (CursorNode.Selected
|
|
||||||
or ((tvoAllowMultiselect in Options) and CursorNode.MultiSelected));
|
|
||||||
LogicalX:=X;
|
|
||||||
|
|
||||||
if (Button = mbRight) and RightClickSelect and
|
|
||||||
(([ssDouble, ssTriple, ssQuad] * Shift) = [])//single right click or first of a multi click
|
|
||||||
then
|
|
||||||
ChangeSelection;
|
|
||||||
|
|
||||||
inherited MouseDown(Button, Shift, X, Y);
|
|
||||||
|
|
||||||
if (Button = mbLeft) and
|
|
||||||
(([ssDouble, ssTriple, ssQuad] * Shift) = [])//single left click or first of a multi click
|
|
||||||
then
|
|
||||||
ChangeSelection;
|
|
||||||
|
|
||||||
// multi click
|
|
||||||
if not (tvoNoDoubleClickExpand in Options) and (ssDouble in Shift)
|
if not (tvoNoDoubleClickExpand in Options) and (ssDouble in Shift)
|
||||||
and (Button = mbLeft) and (CursorNode<>nil) then
|
and (Button = mbLeft) and (CursorNode<>nil) then
|
||||||
CursorNode.Expanded := not CursorNode.Expanded;
|
CursorNode.Expanded := not CursorNode.Expanded;
|
||||||
|
Loading…
Reference in New Issue
Block a user