iOS native gestures


Sorry if this is something low, but would anybody help me with implementing the native iOS gestures. I’m talking about swipe and 2, 3 4-fingered swipe. How to implement those properly in juce? What are the commands? What mouse events and how can I use to achieve those gestures? Any help will be appreciated. Thank you.


There are a couple ways to handle this and a lot depends on what, precisely, you are trying to do.

At it’s simplest, JUCE takes iOS touch began, touch moved, etc. messages and converts them into MouseEvent messages. Multiple touches appear as multiple sources.

See the MouseListener, MouseEvent, and MouseInputSource docs for more details.

Converting these ‘mice’ into gestures is relatively straight forward. iOS didn’t originally include any real knowledge on ‘gestures’, so most original iOS programming books included gesture recognition examples.

Likewise, though the ComponentAnimator is a bit crude, between alpha support and components having a transform affine making the basic switch and slide stuff happen is pretty straight forward.

Where I’ve run into a bit of trouble is when gesture scope and component scope don’t align. Say I have individual components I want to touch/press on the screen, while the overall window accepts gestures (swipe to scroll, etc.) I usually end up futzing with the library code where touches are parsed and distributed. There is a probably a better way. But when I tried futzing with things like a clear top most component that intercepts and conditionally passes on MouseEvents, the serial nature of Juce mouse handling bites me (on the flip side, the Juce->Mouse thing works great for things like multiple sliders on the screen).

You should probably try a search. This has come up a few times and I don’t recall how other people have handled it.