Alberto Rossi Alberto Rossi - 1 year ago 197
Android Question

Firemonkey possible bug with drag and drop

I have noticed that there is something wrong when I use the

event and the
event. Look at this piece of code:

procedure TForm1.Button1DragDrop(Sender: TObject; const [Ref] Data: TDragObject;
const [Ref] Point: TPointF);
var t,d: TButton;

T := TButton(Sender);
D := TButton(Data.Source); := +;
Score(; := 0;
T.isOk := true;


procedure TForm1.Button1DragOver(Sender: TObject; const [Ref] Data: TDragObject;
const [Ref] Point: TPointF; var Operation: TDragOperation);

if ((Sender is TButton) and (Data.Source is TButton) and not(Sender = Data.Source)
and (TButton(Sender).Text = TButton(Data.Source).Text) and (TButton(Data.Source).Text <> '')) then
operation := TDragOperation.Move;
operation := TDragOperation.None;


This code is related to the form that you can see in this picture below:

enter image description here

This is a grid layout with some buttons inside; Button1 is the top-left one and all the other buttons have the events
pointing to Button1 events. For example look.

When I run the program under Windows (target platform win32 bit) I am able to drag and drop the buttons in the grid using the cursor and the mouse. The problem comes out when I move to android because on my mobile I cannot drag and drop buttons. Any idea?

This is a multi-device app built with Firemonkey. I was thinking that I have to declare the DragDrop and DragOver event for every button instead of making a reference to Button1. Could this be?

Answer Source

It is not a bug and you can find the reason here in the documentation; the DragDropService is not implemented in the android platform.

You can use IFMXDragDropService in both Windows and OS X

If you want to make a test I suggest you to try with this line:

if TPlatformServices.Current.SupportsPlatformService(IFMXDragDropService) then
  //test code

In order to be sure that you can use the IFMXDragDropService service, first test whether it is supported.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download