A have a tree: ROOT - VirtualStringTree(You don't see it, TVirtualStringTree.RootNode)
- My Root Node 1
- My Root Node 2
- Second node 1
- Second node 2
- Second node 3
- My Root Node 3
I can Drag'n'Drop "My Root Node 3" to any visible node, but I can't return it to defaut position, to the root level of tree.
I try that:
//Part of code from OnDragDrop Event of VirtualStringTree
if (Sender.DropTargetNode = Sender.RootNode) then
begin
for i := 0 to high(Nodes) do
begin
LinksTree.MoveTo(Nodes[i], Sender.DropTargetNode, Attachmode, False);
end;
end;
I places mouse to nowhere, but nothing happens. In DragOver I accepted drop to root if DropTarget is VST.RootNode.
Anybody knows, how to drop node to VST.RootNode if I drag mouse to empty space of component?
AttachMode
toamInsertBefore
it will be moved to the root. addtoShowDropmark
inPaintOptions
to see the drop mark. My logic is as follow: ifMode
(TDropMode
) isdmAbove
I setAttachMode := amInsertBefore
;dmOnNode -> amAddChildLast
;dmBelow -> amInsertAfter
. – kobikdmNowhere
drop mode and many examples shows assigning theamNoWhere
to the attach mode. And this will be the case, I think, because the call of theMoveTo
looks correct. You can move nodes to theRootNode
(ornil
, which means the same), so the only thing I would suspect is a wrong attach mode. – TLamaamNoWhere
but you were faster :) In any case I DO NOT implementamNoWhere
becouse I think It's wrong UI behavior to move nodes when there is no visible target nodes. – kobikamNoWhere
value just to initialize theAttachMode
local variable. It covers the situation when I forget on a certain drop mode in thecase
statement and that variable has a "random" value as it's local. Otherwise I also prevent no target node case by acceptingOnDragOver
event only if there is a target. – TLamacase
differently: I simplyExit
the event in caseMode==dmNowhere
because I have a bit of logic before I actually callMoveTo
which should not be used in case ofdmNowhere
. – kobik