Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   Delphi Android move Label (https://www.delphipraxis.net/201917-android-move-label.html)

danten 10. Sep 2019 12:04

Android move Label
 
How do I move a Label over a form.
Thank you

mkinzler 10. Sep 2019 12:10

AW: Android move Label
 
Delphi-Quellcode:
Label.Position.X := <X>;
Label.Position.Y := <Y>;

danten 10. Sep 2019 12:28

AW: Android move Label
 
Thank you,
I meant onMouseDown, onMouseUp or onTap.

Schokohase 10. Sep 2019 12:46

AW: Android move Label
 
Delphi-Quellcode:
procedure TFormX.OnMouseUp( ... );
begin
  Label.Position.X := <newX>;
  Label.Position.Y := <newY>;
end;

danten 10. Sep 2019 13:26

AW: Android move Label
 
Thank you, I will answer myself :shock: 8-)
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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:44 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz