mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-21 12:48:17 +02: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 UpdateTooltip(X, Y: integer);
|
||||
procedure InternalSelectionChanged;
|
||||
function AllowMultiSelectWithCtrl(AState: TShiftState): Boolean;
|
||||
function AllowMultiSelectWithShift(AState: TShiftState): Boolean;
|
||||
protected
|
||||
FChangeTimer: TTimer;
|
||||
FEditor: TEdit;
|
||||
|
@ -4041,37 +4041,37 @@ begin
|
||||
|
||||
VK_DOWN:
|
||||
begin
|
||||
MoveToNextNode(ssShift in Shift);
|
||||
MoveToNextNode(AllowMultiSelectWithShift(Shift));
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
VK_UP:
|
||||
begin
|
||||
MoveToPrevNode(ssShift in Shift);
|
||||
MoveToPrevNode(AllowMultiSelectWithShift(Shift));
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
VK_HOME:
|
||||
begin
|
||||
MoveHome(ssShift in Shift);
|
||||
MoveHome(AllowMultiSelectWithShift(Shift));
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
VK_END:
|
||||
begin
|
||||
MoveEnd(ssShift in Shift);
|
||||
MoveEnd(AllowMultiSelectWithShift(Shift));
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
VK_PRIOR: // Page Up
|
||||
begin
|
||||
MovePageUp(ssShift in Shift);
|
||||
MovePageUp(AllowMultiSelectWithShift(Shift));
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
VK_NEXT: // Page Down
|
||||
begin
|
||||
MovePageDown(ssShift in Shift);
|
||||
MovePageDown(AllowMultiSelectWithShift(Shift));
|
||||
Key:=VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
@ -4079,7 +4079,7 @@ begin
|
||||
if not (Key in [VK_LEFT,VK_RIGHT,VK_ADD,VK_SUBTRACT]) then
|
||||
Exit;
|
||||
|
||||
if (tvoAllowMultiSelect in FOptions) and (ssShift in Shift) then
|
||||
if (tvoAllowMultiSelect in FOptions) and AllowMultiSelectWithShift(Shift) then
|
||||
lNode := FTreeNodes.FLastMultiSelected
|
||||
else
|
||||
lNode := Selected;
|
||||
@ -4121,7 +4121,7 @@ begin
|
||||
end;
|
||||
|
||||
if lNode <> nil then
|
||||
MoveSelection(lNode, ([ssShift] * Shift) <> []);
|
||||
MoveSelection(lNode, AllowMultiSelectWithShift(Shift));
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -5361,7 +5361,7 @@ begin
|
||||
//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
|
||||
not AllowMultiSelectWithCtrl(Shift) and//only when CTRL is not pressed
|
||||
(CursorNode <> nil) and
|
||||
(LogicalX >= CursorNode.DisplayStateIconLeft)//only after expand sign
|
||||
then
|
||||
@ -5409,17 +5409,17 @@ begin
|
||||
Selected := CursorNode
|
||||
else
|
||||
begin
|
||||
if (ssShift in Shift) then
|
||||
if AllowMultiSelectWithShift(Shift) then
|
||||
begin
|
||||
Exclude(FStates,tvsEditOnMouseUp);
|
||||
LockSelectionChangeEvent;
|
||||
try
|
||||
Items.MultiSelect(CursorNode, not(ssCtrl in Shift));
|
||||
Items.MultiSelect(CursorNode, not AllowMultiSelectWithCtrl(Shift));
|
||||
finally
|
||||
UnlockSelectionChangeEvent;
|
||||
end;
|
||||
end
|
||||
else if (ssCtrl in Shift) then
|
||||
else if AllowMultiSelectWithCtrl(Shift) then
|
||||
begin
|
||||
Exclude(FStates,tvsEditOnMouseUp);
|
||||
CursorNode.MultiSelected:=not CursorNode.MultiSelected;
|
||||
@ -5820,6 +5820,16 @@ begin
|
||||
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;
|
||||
begin
|
||||
inherited WSRegisterClass;
|
||||
@ -6022,7 +6032,7 @@ end;
|
||||
|
||||
procedure TCustomTreeView.Select(Node: TTreeNode; ShiftState: TShiftState = []);
|
||||
begin
|
||||
if (tvoAllowMultiSelect in FOptions) and (ssCtrl in ShiftState) then
|
||||
if (tvoAllowMultiSelect in FOptions) and AllowMultiSelectWithCtrl(ShiftState) then
|
||||
Node.Selected := True
|
||||
else begin
|
||||
ClearSelection;
|
||||
|
Loading…
Reference in New Issue
Block a user