TMSFMXDirectoryTreeView Drag and Drop

I have a  DirectoryTreeView and an FMXDropTarget component sitting on my form. I want to be able to drag files out of the DirectoryTreeView and drop them on the Drop Target, preferably with multiple selections. I know how to handle the files when they are dropped onto the Drop Target, but I'm having problems selecting and starting the drag operation in the TMSFMXDirectoryTreeView component.

I can set the Interaction.MultiSelect, and Interaction.ExtendedSelectable properties  OK  when DragMode is the default value, but setting the DirectoryTreeview.DragMode to DragMode.dmAutomatic stops me from selecting any nodes at all, and shows the entire control window when I drag. There doesn't appear to be any OnStartDrag event handler like there is with vcl either.

I need assistance please, I'm stuck!!

Hi, 


Drag and drop is currently not supported. The drag and drop mode and events are inherited from a FireMonkey TControl. When setting DragMode to Automatic, the complete control is dragged, because the nodes aren't real controls, but are painted instead for performance reasons.

We will investigate what is possible to add drag and drop support.

Kind Regards, 
Pieter

Thanks for the fast reply Pieter.
So these drag mode and events aren't useable? If they act on the whole DirectoryTreeCiew object, then could the whole TreeView be dropped on the drop target, and then it might be possible to extract the selected nodes text from the object when dropped? Then all I'd need is some way to change the drag image, and some way to make it possible to do the multi selection when DragMode is set to dmAutomatic.

At the moment I'm trying to drop a DirectoryTreeView onto the drop target, but the droptarget won't let me, and the on line help documentation for FMX.ExtControls.TDropTarget tells me to set Accept := true in the DragOver event, to accept any object, but Delphi won't compile that instruction. So I'm stuffed at both ends :-{

Drag & drop is implemented at FireMonkey control level. You will need to manually construct a TDragObject record and then you can use the IFMXDragDropservice to begin a drag / drop operation. Below is some sample code to get you started. 


procedure TForm111.TMSFMXDirectoryTreeView1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
  FMouseDown := True;
end;

procedure TForm111.TMSFMXDirectoryTreeView1MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Single);
var
  vn: TTMSFMXTreeViewVirtualNode;
  ddService: IFMXDragDropService;
  d: TDragObject;
begin
  vn := TMSFMXDirectoryTreeView1.XYToNode(X, Y);
  if Assigned(vn) and FMouseDown then
  begin
    if TPlatformServices.Current.SupportsPlatformService(IFMXDragDropService, DDService) then
    begin
      d.Source := vn;
      DDService.BeginDragDrop(Self, d, TMSFMXDirectoryTreeView1.MakeScreenshot);
    end;
  end;
end;

procedure TForm111.TMSFMXDirectoryTreeView1MouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
  FMouseDown := False;
end;

Kind Regards,
Pieter