Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOS

Access True Real Time Multitouch Coordinates With Delphi XE5 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE5 Firemonkey True Multitouch | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSApparently Delphi XE5 Firemonkey doesn’t have true multitouch coordinates exposed to the developer by default. Iztok Kacin has a blog post up where he shows how to overcome this challenge and provides source code so you can do the same. What Delphi XE5 does do is have a complete event that fires at the end of a gesture but does not provide you real time access to the multitouch coordinates by default. His solution is a pretty straightforward unit for including into your Android projects but you will have to customize the Delphi FMX.Platform.IOS file yourself to make it work on IOS. This code looks very similar to how multitouch works under Adobe AIR. Here is the sample usage from his OnTouchEvent:
function TForm1.PointsToString(const Event: TTouchEvent): string;
var
I: Integer;
begin
Result := '';

for I := 0 to Length(Event.Points) - 1 do
begin
if I = 0 then
Result := Format('[%f:%f]', [Event.Points[I].Position.X,
Event.Points[I].Position.Y])
else
Result := Result + ' ' + Format('[%f:%f]', [Event.Points[I].Position.X,
Event.Points[I].Position.Y]);
end;
end;

procedure TForm1.OnTouchEvent(const Event: TTouchEvent);
begin
lbMultiTouch.Items.BeginUpdate;
try
case Event.EventType of
teDown: lbMultiTouch.Items.Add(Format('DOWN: %s', [PointsToString(Event)]));
teMove: lbMultiTouch.Items.Add(Format('MOVE: %s', [PointsToString(Event)]));
teUp: lbMultiTouch.Items.Add(Format('UP: %s', [PointsToString(Event)]));
end;
finally
lbMultiTouch.Items.EndUpdate;
end;
end;

Update: Second blog post with patch free multitouch fix for IOS.
Update: Third blog post with touched control and relative coordinates.

Head over to his blog to download the source code and find out how to patch your IOS file.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

Leave a Reply