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