Thema: Delphi Android move Label

Einzelnen Beitrag anzeigen

danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#5

AW: Android move Label

  Alt 10. Sep 2019, 13:26
Thank you, I will answer myself
Delphi-Quellcode:
var
  FrmMain: TFrmMain;
  MouseDownPos: TPoint;
  DragEnabled : Boolean;

implementation

{$R *.fmx}

procedure TFrmMain.Label1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  MouseDownPos.X := Round(X);
  MouseDownPos.Y := Round(Y);
  DragEnabled := True;
end;

procedure TFrmMain.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Single);
begin
  if DragEnabled then
     begin
        Label1.Position.X := Label1.Position.X + (X - MouseDownPos.X);
        Label1.Position.Y := Label1.Position.Y + (Y - MouseDownPos.Y);
     end;
end;

procedure TFrmMain.Label1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  if DragEnabled then
     begin
        Label1.Position.X := Label1.Position.X + (X - MouseDownPos.X);
        Label1.Position.Y := Label1.Position.Y + (Y - MouseDownPos.Y);
     end;
end;
Daniel
  Mit Zitat antworten Zitat