How to record multitouch gestures in Kivy?

喜夏-厌秋 提交于 2019-12-23 04:52:40

问题


I have used the gestures code based on the provided Kivy examples to record and recognize single touch gestures. However, I am not sure how to extend this code to recognize multi-touch gestures. Let's say, for example, a pinch.

My problem becomes specially complicated because I use a laptop with zero multi-touch functionality. How do I combine two single gestures? Is there any example available?


回答1:


From 1.9.0, Kivy got a multi-touch gesture recognizer integrated: have a look at kivy.multistroke. I personally didn't got time to test it yet.

If you want to map or act depending of the gesture, you might be interested by the Scatter. Pinch can be done with 2 to N touch, with rotation and translation integrated. You can restrict the transformation to just scale and not rotation / translation. And, when all the touches are released, you could animate the scale to the closest wanted value. You can also set a limit for the minimum scale and maximum scale.

With few parameters and code, you can pinch to zoom, de/un pinch to unzoom, etc. Maybe that's what you want :) (like pinch to zoom in a image, or put an image in fullscreen).

You can also just use the Scatter's scale parameters, or Scale's matrix to do your own things :)



来源:https://stackoverflow.com/questions/27210370/how-to-record-multitouch-gestures-in-kivy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!