Delphi android drag and drop buttons

  

SITUATION

I am using Delphi Seattle and I want to develop a very simple game.

As you can see here I here I have a grid layout and the grey squares are TButtons. My goal is to be able to move (for example) the top-left button with the number 2 above the other button below with the number 2. I have written this code:

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

T := TButton(Sender);
D := TButton(Data.Source);
T.data := T.data + D.data; //sum 2 + 2

//… other code, not relevant …

end;

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

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
begin
operation := TDragOperation.Move;
end
else
begin
operation := TDragOperation.None;
end;

end;

When I run this as 32-bit windows program it works fine. I am able to click on a button with the number 2 and perform a drag & drop on another button having the number 2.

PROBLEM

This program in my Android device doesn’t work because I cannot perform the drag and drop. I have already seen some example online about this, but I cannot find a specific solution for my problem.

What could I do?

Comments are closed.