4
« on: January 14, 2014, 12:19:38 PM »
I want to distinguish between Tap events and Tap and Hold events in a way that the Tap and Hold events take precedence - basically, if the user holds their finger down anywhere on the screen (including on a button, which may have an associated OnClick event), a particular event should fire (and the OnClick handler for that button would be ignored), but if they just tap quickly on a button, the OnClick event should fire. I am thinking of implementing something like this:
- A giant invisible sprite which fills the screen and has an OnPress Handler
- Various buttons on the screen that have OnClick handlers
When the user taps the screen, the OnPress handler should fire and test if the tap duration is longer than a certain threshold. If it is, it should do whatever I want it to do when the user Taps and Holds (in this case, display some additional UI elements). If it is less than the threshold, it is just a Tap, and the event handling should fall through to the OnClick handler of whatever button the user tapped.
Is this possible? This is sort of the opposite of the question I asked last week, where I wanted the OnClick events to take precedence and catch any taps/clicks that fell through - now, I want to first test whether the user is pressing their finger down and let that take precedence, and only fire the OnClick events in the case of a short tap.