mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-21 12:40:37 +01:00
LCL: Implement TTreeView.MultiSelectStyle. Issue #18043, patch from AlexeyT.
git-svn-id: trunk@54187 -
This commit is contained in:
parent
82a7e6d0c7
commit
55b51f1788
@ -3383,6 +3383,8 @@ type
|
|||||||
procedure UpdateScrollbars;
|
procedure UpdateScrollbars;
|
||||||
procedure UpdateTooltip(X, Y: integer);
|
procedure UpdateTooltip(X, Y: integer);
|
||||||
procedure InternalSelectionChanged;
|
procedure InternalSelectionChanged;
|
||||||
|
function AllowMultiSelectWithCtrl(AState: TShiftState): Boolean;
|
||||||
|
function AllowMultiSelectWithShift(AState: TShiftState): Boolean;
|
||||||
protected
|
protected
|
||||||
FChangeTimer: TTimer;
|
FChangeTimer: TTimer;
|
||||||
FEditor: TEdit;
|
FEditor: TEdit;
|
||||||
|
|||||||
@ -4041,37 +4041,37 @@ begin
|
|||||||
|
|
||||||
VK_DOWN:
|
VK_DOWN:
|
||||||
begin
|
begin
|
||||||
MoveToNextNode(ssShift in Shift);
|
MoveToNextNode(AllowMultiSelectWithShift(Shift));
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_UP:
|
VK_UP:
|
||||||
begin
|
begin
|
||||||
MoveToPrevNode(ssShift in Shift);
|
MoveToPrevNode(AllowMultiSelectWithShift(Shift));
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_HOME:
|
VK_HOME:
|
||||||
begin
|
begin
|
||||||
MoveHome(ssShift in Shift);
|
MoveHome(AllowMultiSelectWithShift(Shift));
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_END:
|
VK_END:
|
||||||
begin
|
begin
|
||||||
MoveEnd(ssShift in Shift);
|
MoveEnd(AllowMultiSelectWithShift(Shift));
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_PRIOR: // Page Up
|
VK_PRIOR: // Page Up
|
||||||
begin
|
begin
|
||||||
MovePageUp(ssShift in Shift);
|
MovePageUp(AllowMultiSelectWithShift(Shift));
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
VK_NEXT: // Page Down
|
VK_NEXT: // Page Down
|
||||||
begin
|
begin
|
||||||
MovePageDown(ssShift in Shift);
|
MovePageDown(AllowMultiSelectWithShift(Shift));
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4079,7 +4079,7 @@ begin
|
|||||||
if not (Key in [VK_LEFT,VK_RIGHT,VK_ADD,VK_SUBTRACT]) then
|
if not (Key in [VK_LEFT,VK_RIGHT,VK_ADD,VK_SUBTRACT]) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
if (tvoAllowMultiSelect in FOptions) and (ssShift in Shift) then
|
if (tvoAllowMultiSelect in FOptions) and AllowMultiSelectWithShift(Shift) then
|
||||||
lNode := FTreeNodes.FLastMultiSelected
|
lNode := FTreeNodes.FLastMultiSelected
|
||||||
else
|
else
|
||||||
lNode := Selected;
|
lNode := Selected;
|
||||||
@ -4121,7 +4121,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if lNode <> nil then
|
if lNode <> nil then
|
||||||
MoveSelection(lNode, ([ssShift] * Shift) <> []);
|
MoveSelection(lNode, AllowMultiSelectWithShift(Shift));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5361,7 +5361,7 @@ begin
|
|||||||
//change selection on right click
|
//change selection on right click
|
||||||
if (Button = mbRight) and RightClickSelect and//right click
|
if (Button = mbRight) and RightClickSelect and//right 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
|
||||||
not(ssCtrl in Shift) and//only when CTRL is not pressed
|
not AllowMultiSelectWithCtrl(Shift) and//only when CTRL is not pressed
|
||||||
(CursorNode <> nil) and
|
(CursorNode <> nil) and
|
||||||
(LogicalX >= CursorNode.DisplayStateIconLeft)//only after expand sign
|
(LogicalX >= CursorNode.DisplayStateIconLeft)//only after expand sign
|
||||||
then
|
then
|
||||||
@ -5409,17 +5409,17 @@ begin
|
|||||||
Selected := CursorNode
|
Selected := CursorNode
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if (ssShift in Shift) then
|
if AllowMultiSelectWithShift(Shift) then
|
||||||
begin
|
begin
|
||||||
Exclude(FStates,tvsEditOnMouseUp);
|
Exclude(FStates,tvsEditOnMouseUp);
|
||||||
LockSelectionChangeEvent;
|
LockSelectionChangeEvent;
|
||||||
try
|
try
|
||||||
Items.MultiSelect(CursorNode, not(ssCtrl in Shift));
|
Items.MultiSelect(CursorNode, not AllowMultiSelectWithCtrl(Shift));
|
||||||
finally
|
finally
|
||||||
UnlockSelectionChangeEvent;
|
UnlockSelectionChangeEvent;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else if (ssCtrl in Shift) then
|
else if AllowMultiSelectWithCtrl(Shift) then
|
||||||
begin
|
begin
|
||||||
Exclude(FStates,tvsEditOnMouseUp);
|
Exclude(FStates,tvsEditOnMouseUp);
|
||||||
CursorNode.MultiSelected:=not CursorNode.MultiSelected;
|
CursorNode.MultiSelected:=not CursorNode.MultiSelected;
|
||||||
@ -5820,6 +5820,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomTreeView.AllowMultiSelectWithCtrl(AState: TShiftState): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (ssCtrl in AState) and (msControlSelect in FMultiSelectStyle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomTreeView.AllowMultiSelectWithShift(AState: TShiftState): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (ssShift in AState) and (msShiftSelect in FMultiSelectStyle);
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TCustomTreeView.WSRegisterClass;
|
class procedure TCustomTreeView.WSRegisterClass;
|
||||||
begin
|
begin
|
||||||
inherited WSRegisterClass;
|
inherited WSRegisterClass;
|
||||||
@ -6022,7 +6032,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomTreeView.Select(Node: TTreeNode; ShiftState: TShiftState = []);
|
procedure TCustomTreeView.Select(Node: TTreeNode; ShiftState: TShiftState = []);
|
||||||
begin
|
begin
|
||||||
if (tvoAllowMultiSelect in FOptions) and (ssCtrl in ShiftState) then
|
if (tvoAllowMultiSelect in FOptions) and AllowMultiSelectWithCtrl(ShiftState) then
|
||||||
Node.Selected := True
|
Node.Selected := True
|
||||||
else begin
|
else begin
|
||||||
ClearSelection;
|
ClearSelection;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user