Enable Multitouch on FireMonkey for IOS » ObjectUp Studio Blog

发布时间:2017-1-21 2:06:36 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"Enable Multitouch on FireMonkey for IOS » ObjectUp Studio Blog",主要涉及到Enable Multitouch on FireMonkey for IOS » ObjectUp Studio Blog方面的内容,对于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) We add the new event in the TCommonCustomForm classe. 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. And, the last but not the least, and certainly the most important : Do not forget to enable Multitouch from the ground a this place 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

上一篇:金蝶KIS 异地应用解决方案