I'm writing an Android app in delphi 10.4.2 and when I write the scaling code in the OnGesture event of the image1 control, the IDE says "uncleared identifier" for the ScaleFactor. I've looked at it repeatedly, but I don't know where the problem is coming from, so I'm looking for help.
Here is my code:
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, FMX.Layouts,
FMX.ExtCtrls,
FMX.Gestures,
FMX.Edit,
System.IOUtils;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
ImageViewer1: TImageViewer;
Image1: TImage;
GestureManager1: TGestureManager;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ImageViewer1Gesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
procedure Image1Gesture(Sender: TObject; const EventInfo: TGestureEventInfo;
var Handled: Boolean);
private
{ Private declarations }
FLastDistance: Integer;
const MIN_DIM = 100;
public
{ Public declarations }
end;
var
Form1: TForm1;
G_lujing:string='';
G_myDir:string='MyBrain';
implementation
{$R *.fmx}
{$R *.LgXhdpiTb.fmx ANDROID}
{$R *.SmXhdpiPh.fmx ANDROID}
{$R *.iPhone55in.fmx IOS}
procedure TForm1.FormCreate(Sender: TObject);
var path: string; fileName:string;
begin
path:=TPath.GetSharedDownloadsPath;
path := TPath.GetDirectoryName(path);
G_lujing:=TPath.Combine(path, G_myDir);
try
if not TDirectory.Exists(G_lujing) then TDirectory.CreateDirectory(G_lujing);
fileName := TPath.Combine(G_lujing, 'test.txt');
if not FileExists(fileName) then TFile.WriteAllText(fileName, 'Hello world!');
except on
E: Exception do ShowMessage('An error occurred while creating the directory:' + E.Message);
end;
end;
procedure TForm1.Image1Gesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
if EventInfo.GestureID = igiZoom then
begin
// Zoom the image using ScaleFactor
Image1.Scale.X := Image1.Scale.X * EventInfo.ScaleFactor;
Image1.Scale.Y := Image1.Scale.Y * EventInfo.ScaleFactor;
// Adjust the image position based on the gesture focus point
Image1.Position.Point := EventInfo.FocusPoint;
end;
end;
end.