Double Tap recognition
See original GitHub issueHello,
I want to use a double Tap gesture. I noticed, that the InputClickedEventData provides a TapCount.
But when I try the follwoing, only the Signle Tap
is displayed.
Am I missing something? Or do I need to set up some timer to recognize two single Taps in a short time?
public void OnInputClicked(InputClickedEventData eventData)
{
if (eventData.TapCount > 1)
Debug.Log("Double Tap");
else
Debug.Log("Single Tap");
}
Thanks in advance.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
DT0101 Design tip - Setting up single-tap and double-tap ...
The single-tap and double-tap recognition feature allows detecting actions similar to the single click and double click of a mouse. The ...
Read more >How to detect a double tap gesture
The iOS UITapGestureRecognizer class has a built-in way to detect a double tap on any view. All you need to do is create...
Read more >NeoReader Double-Tap Recognition : r/Onyx_Boox
In NeoReader, hand-written notes can be recognized by double-tapping on it. Is there a way to change the font size of the recognized...
Read more >DoubleTap recognition in UITableView
I have setup a pair of UITapGestureRecognizers to try to catch single and double taps on a UITableView. When the tap handler is...
Read more >Android Tap, Double Tap, Pan and Pinch Gestures ...
Android Tap, Double Tap, Pan and Pinch Gestures Recognising — part 1. How to use Android Gesture recognizers and handle view touch events ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Honestly, if we have to check the tap count and wait for seconds to tell the difference between a single and double tap, then the double tap functionality is not really in place. If it were, there would be a DoubleTap Event and the system would handle all this. So it may be best to roll your own for now, it’s the same amount of code and less hassle.
I have not been able to get double-tap to work with the IPointerClickHandler, I only get zeros as the clickCount. You’ll need to have EventSystem added to the scene for IPointerClickEvents to occur. Just add a UI button to the scene and the EventSystem comes in as well.
I was able to get double-taps to work using IInputClickHandler and OnInputClicked(InputClickedEventData eventData) though.
First thing is the GesturesInput is not setup to handle double-tap detection, so you need to add it to the recognizable gestures by opening HoloToolkit/UI/Scripts/InputSources/GesturesInput.cs
On line 46 add GestureSettings.DoubleTap to the gestureRecognizer like this.
gestureRecognizer.SetRecognizableGestures(GestureSettings.Tap | GestureSettings.ManipulationTranslate | GestureSettings.Hold | GestureSettings.DoubleTap);
Then in the OnInputClicked handler look at the tapCount which should be 1 or 2.
public virtual void OnInputClicked(InputClickedEventData eventData) { print(eventData.TapCount); }
Two events will fire on a double-tap (1 and 2), so if you want to capture both single-taps and double-taps on the same object, you will have to delay the single-tap execution to see if a double-tap does not immediately follow. I hope that makes sense.
Maybe there’s a part of the EventSystem that needs to register to listen for double taps to get the IPointer stuff working, but I haven’t dug that far into it yet.