Jump to content
Just one word of caution:
Whoever uses this workaround needs to pay close attention to the fixes done by Coronalabs:
As soon as the normal key behavior is fixed and the system key events are thrown again for up / down / left / right you then will get all directions twice - you then need to take out my temporary fix.
A permanent solution would be to change the custom keys thrown to "customUp", "customDown", "customRight" and "customLeft" and then listen for these keys names. It then would be no problem if one day the normal key events are thrown again, because "up", "down" etc. are ignored.
Andreas, thank you very much for the code snippet. I was able to get it working immediately.
One question I have is how do you modify this so that when the user swipes right AND the finger remains down the "right" event keeps repeating. Imagine if you will the behavior when the on screen keyboard is shown, you can continue swiping across multiple letters while holding your finger down (no need to keep physically swiping right across each letter). I am needing to replicate this. Any help is appreciated!
I'm traveling right now for a week, and I don't have my Apple TV with me. ;-)
So just an idea:
The problem is to know when the swipe ended. And there is no kind of "fingerUp" event.
But maybe you can check if the touch traveled more than a absolute normalized distance of 0.3 multiplied with a counter that starts with 1 and is incremented after each key event dispatched.
In the beginning you check for the touch travel distance of > 0.3 * counter (and counter = 1 by default), and if the distance is > 0.3 you dispatch the first key and inc the counter.
Then you automatically check again for distance > 0.3 * counter (now this is evaluates to checking for > 0.6, because counter is 2) and if this value is reached you dispatch the next key event and inc the counter again, etc.
For the breaking condition to break this distance check you can test if the touch traveled a minimum distance between two events. Or check if the time between two events is too big. Both cases would indicate that the user stopped the swipe. Now you reset everything, and you start again to watch for the next swipe.
I guess with this method you get what you want, and then you can play around with the numbers a little bit, e.g. use a check for > 0.4 if the method is too sensitive.
Good luck, and when you solve it feel free to post your solution, I would be interested to see how you solved this!
found something, maybe this bridge was already crossed and you can use or adapt the code posted here:
If you are successful with this please tell me! :-)
Community Forum Software by IP.Board