Enable Multitouch on FireMonkey for IOS » ObjectUp Studio Blog

Hi Everybody,

For near a year now, Embarcadero (EMB) released a new top product : Delphi XE2. It allows, among other functions, cross platform developement.

One of this target platform is Apple Ios. As Delphi XE2 is acting here as a middleware, we get the main advantage of it : very few modification between target platform. But as a middleware, the main disavantage is that specificity of each platform is hidden, and unfortunaly, often, forget – Sacrified upon interoperability case.

One of this *huge* forget for me is one of the top functionnality of IOS device : Multitouch. I was very stonish to see the following facts, when delphi XE2 was out :

1 – No multitouch at all on the Firemonkey IOS platform.

2 – I dug alittle in the code, and find easely where the multitouch is volontary hidden – we can even say  stiffle – with a  (pseudo) code as is :

<code>

e : NSSet;

e := GetTouch;

if e.TouchCount>1 then Exit (!)

</code>

This code is certainly here for a good reason, but, frankly, I did not undestand why.

So, I modify a little (a minimum, in fact) the 2 above units in order to take care of multitouch easely.

FMX_Forms (IOS)

FMX_Platform_IOS

I will not provide the files, since it is right protected, instead, I will describt where you have to change the stuff. Anyway, you will have to do that at each update of Firemonkey.

WARNING : Make a copy of those files before update, they are all part of the subsystem of firemonkey, and if you are not in touch with those files and consequences that could summon as border effect, please, wait for EMB to officialy support the multitouch : Or go to Objective-c

I choose to put the multitouch in a new event, instead of summon a OnMouseMove for each touch event, we will summon a OnMultiTouch event for each touch, in the event, you’ll find an integer that give your the touch order.

The advantage of this approach is twice : Modification are smaller, simpler, and well delimited – And – you do not have to change existing code : Only link the OnMultitouch event in your code to detect it : the onMouseXXXX event will not change, and will be always act as before.

1) Update FMX_Forms

Add to this unit the fellowing statement :

First our new type for multitouch : (Click on picture to obtain all informations)

Enable Multitouch on FireMonkey for IOS raquo; ObjectUp Studio Blog - yyimen - yyimen的博客

We add the new event in the TCommonCustomForm classe.

Enable Multitouch on FireMonkey for IOS raquo; ObjectUp Studio Blog - yyimen - yyimen的博客

Remember to generate the counterpart variable in private part : (hit ctrl-shift-c on property declaration to generate)

2) Update FMX.Forms

Since I work on XCode, I do not have put this modification on Windows side : If you do, do not forget you certainly have to recompile all the mess in order to get OnMultitouch code compile under windows : And for useless, since it is not supported by this component (there a bunch of other comps to do that).

I recommand you to not do that. Put the IOS code between compilation directive to be silent under windows and only active under XCode : {$IFDEF FPC} is you friend.

3) Update FMX_Plateform_IOS

This is the gratest part : we will code the OnMultiTouch event management.

It is very simple, we have 3 events liked to delegate in this code :


procedure
TUIView.touchesBegan_withEvent(touches: NSSet; event: UIEvent);
procedure TUIView.touchesMoved_withEvent(touches: NSSet; event: UIEvent);
procedure TUIView.touchesEnded_withEvent(touches: NSSet; event: UIEvent);

If you want, you can modify the three, but, in this case, I recommand you to put the fellowing events in the FMX_Forms

OnMultitouchEventDown

OnMutlitouchEventMove

OnMultitouchEventUp

In my case, the move is suffisant, so, I show here how to modify this procedure : (the 2 other is the same, juste the Form.onMultitouch will differ)

procedure TUIView.touchesMoved_withEvent(touches: NSSet; event: UIEvent);

The code is pretty simple : It loop in all detected touch and summon the event at the right place on the form.

Enable Multitouch on FireMonkey for IOS raquo; ObjectUp Studio Blog - yyimen - yyimen的博客

And, the last but not the least, and certainly the most important : Do not forget to enable Multitouch from the ground a this place

Enable Multitouch on FireMonkey for IOS raquo; ObjectUp Studio Blog - yyimen - yyimen的博客

Yes, by default, the Firemonkey Frameword disable the Multitouch !

Hope it will help you, feel free to contact me if you have question or remark !

Bye !

Vincent,-

This post has no tag

You must be logged in to post a comment.

Except where otherwise noted, content on this site is licensed under a .

uses Graphene theme by Syahir Hakim.




引文来源   Enable Multitouch on FireMonkey for IOS » ObjectUp Studio Blog
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值