VirtualTrees: If a new node is selected by left click or key, OnChange event should not fire with nil in-between.

c8fa85a54c

git-svn-id: trunk@58276 -
This commit is contained in:
ondrej 2018-06-14 21:44:03 +00:00
parent 5b51ac5bd6
commit 8792eb0358

View File

@ -2544,6 +2544,7 @@ type
procedure Change(Node: PVirtualNode); virtual;
procedure ChangeScale(M, D: Integer); override;
function CheckParentCheckState(Node: PVirtualNode; NewCheckState: TCheckState): Boolean; virtual;
procedure ClearSelection(pFireChangeEvent: Boolean); overload; virtual;
procedure ClearTempCache; virtual;
function ColumnIsEmpty(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual;
function ComputeRTLOffset(ExcludeScrollBar: Boolean = False): Integer; virtual;
@ -3005,7 +3006,7 @@ type
function CanEdit(Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual;
procedure Clear; virtual;
procedure ClearChecked;
procedure ClearSelection;
procedure ClearSelection; overload;
function CopyTo(Source: PVirtualNode; Tree: TBaseVirtualTree; Mode: TVTNodeAttachMode;
ChildrenOnly: Boolean): PVirtualNode; overload;
function CopyTo(Source, Target: PVirtualNode; Mode: TVTNodeAttachMode;
@ -16724,7 +16725,7 @@ begin
ForceSelection := False;
if ClearPending and ((LastFocused <> FFocusedNode) or (FSelectionCount <> 1)) then
begin
ClearSelection;
ClearSelection(False);
ForceSelection := True;
end;
@ -22297,7 +22298,7 @@ begin
end;
end
else if not ((hiNowhere in HitInfo.HitPositions) and (toAlwaysSelectNode in Self.TreeOptions.SelectionOptions)) then // When clicking in the free space we don't want the selection to be cleared in case toAlwaysSelectNode is set
ClearSelection;
ClearSelection(False);
end;
// pending node edit
@ -22362,6 +22363,9 @@ begin
end;
end;
if SelectedCount = 0 then
Change(nil);
// Drag'n drop initiation
// If we lost focus in the interim the button states would be cleared in WM_KILLFOCUS.
if AutoDrag and IsAnyHit and (FStates * [tsLeftButtonDown, tsRightButtonDown, tsMiddleButtonDown] <> []) then
@ -25810,7 +25814,7 @@ end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.ClearSelection;
procedure TBaseVirtualTree.ClearSelection(pFireChangeEvent: Boolean);
var
Node: PVirtualNode;
@ -25847,12 +25851,21 @@ begin
end;
InternalClearSelection;
Change(nil);
if pFireChangeEvent then
Change(nil);
end;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TBaseVirtualTree.ClearSelection;
begin
ClearSelection(True);
end;
//----------------------------------------------------------------------------------------------------------------------
function TBaseVirtualTree.CopyTo(Source: PVirtualNode; Tree: TBaseVirtualTree; Mode: TVTNodeAttachMode;
ChildrenOnly: Boolean): PVirtualNode;