MouseUP event on 4 finger SWIPE


#1

Hello,

Does juce send ‘mouseUp’ event to downed buttons when a 4 fingers swipe is performed ?
It seems to not, the Apple api does though. Is there any trick to catch this ‘swipe’ event on juce to “mouseUp” downed buttons manually ?

Thanks in advance for your answer


#2

Sorry, don’t fully understand what you mean… This is OSX, right, not iOS? And by a 4-finger swipe you mean that it’s changing between multiple screens?


#3

Escuse me, I wasn’t very clear indeed.
This is in iOS.
The 4 fingers swipe is when you switch between running applications. (since iOS 5)


#4

Huh? Not on my iphone, it doesn’t… (?)


#5

It’s an iPad only thing.


#6

Don’t forget there is a General setting to enable/disable the multitouch gestures. Some games require that you turn it off.


#7

It’s iPad only and you turn it on and off with “Multitasking Gestures”. Sorry, everything is bootcamped in Windows at the moment, but I think that all you would need to handle is touchesCancelled:withEvent:, then you can send a matching mouse-up to the mouse-dn generated for the touchesBegan that you received. Sorry, it’s been awhile since I looked at your iOS touch handling, but if this is still open at the end of the week I can put together a snippet.


#8

But the code does handle touchesCancelled:…

RaidenZ, you’re not using some old version of juce, are you?


#9

FWIW, I finally got a chance to look at this and the current tip seems fine, at least on my iPad running iOS6.


#10

I found out where the problem is coming from and I fixed it.
It took me time to answer because I wanted to be sure that this is not my code having problems.
It actually comes from JUCE.
I explain :

I have the latest version (did a clone yesterday)
eventCancelled is caught indeed, the problem is not coming from here.
When 4 simultaneous touches are performed and the ‘4 fingered swipe’ is triggered by the IPad, 4 touchesCancel are sent (for each finger). (this works fine)

The problem is just afterwards, in the method “UIViewComponentPeer::handleTouches” (juce_ios_UIVIewComponentPeer.mm) when JUCE calls “currentTouches.getIndexOfTouch()” [line780]
The returned touch indexes were always [0, 0, 0 ,0] or something like [2, 0, 0, 0] instead of returning for exemple [1, 0, 2, 3]
And this is because of all the indexes weren’t returned that I was receiving only half of the MouseUP events.

when currentTouches.getIndexOfTouch() is called and returns an index, it remembers which index it has been returned by saving it in an Array. I figured out that this Array is always empty at the next call of currentTouches.getIndexOfTouch().
This is simply because the array is cleared each time a touch is processed when in cancel, so currentTouches.getIndexOfTouch() always return the same value as it’s the first time it is called.

to resolve the problem this (code below) had to be replaced in “UIViewComponentPeer::handleTouches” (juce_ios_UIVIewComponentPeer.mm) (line 811):

if (isCancel) { -- currentTouches.clear(); ++ currentTouches.clearTouch (touchIndex); modsToSend = currentModifiers = currentModifiers.withoutMouseButtons(); }

So now, all mouseUP are triggered.
Am I clear enough ?

Thanks


#11

Thanks!

That does seem to make sense… I’m a little bit apprehensive because I vaguely remember there being some kind of subtle reason why it clears all of the touch events… but since I can’t think why that would be the case, I’ll go with your suggestion!