I have a VST with toFullRowSelect
(with a few columns). I would like to enable drag & drop on the nodes.
The problem is that you can start draging the node/s only if you click direcly on the node caption. if the click was made on the row selection but not on the node caption, the drag operation will not start and OnDragAllowed
wont fire.
The MCVE is simple. drop a TVirtualStringTree
(name it VST
) on the form and add OnCreate
, and OnDragAllowed
for the VST:
procedure TForm1.FormCreate(Sender: TObject);
begin
VST.TreeOptions.SelectionOptions := VST.TreeOptions.SelectionOptions + [toFullRowSelect];
VST.RootNodeCount := 5;
end;
procedure TForm1.VSTDragAllowed(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean);
begin
Allowed := True;
end;
Now, if you click on a node caption, the drag operation starts, but not if you try to drag other area of the selected node.
How can this be resolved? Thanks.
Include toFullRowDrag option into the MiscOptions option set:
procedure TForm1.FormCreate(Sender: TObject);
begin
VST.TreeOptions.SelectionOptions := VST.TreeOptions.SelectionOptions + [toFullRowSelect];
VST.TreeOptions.MiscOptions := VST.TreeOptions.MiscOptions + [toFullRowDrag];
VST.RootNodeCount := 5;
end;
The toFullRowDrag option is in the source code described as:
Start node dragging by clicking anywhere in it instead only on the caption or image. Must be used together with toDisableDrawSelection.