Apparently 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.
2 Comments