388 views
in GUI Development by
I would like to handle a double-tap differently from a single tap event. I have placed a simple touch handler (min and max strike count set to 1) and a slot tied to the OnRelease. Works great. I then added a simple touch handler on top, with min and max strike count set to 2, and a slot tied to the OnRelease. Also works. The problem is that a double-touch triggers both handlers. As soon as the first touch occurs, the single handler senses it. How can I handle the double tap without the single tap sensing it? Do I need to use the long touch feature?

Thank you.

1 Answer

0 votes
by
 
Best answer

Hello,

from technical point of view, a double tap is composed of two single taps performed very quickly. The Touch Handler interprets a double tap as two separate single taps. In order to distinguish between a double and single tap, you have to delay the processing of a single tap. Following could a possible implementation:

Step 1: Use only one Simple Touch Handler and configure its properties MinStrikeCount = 1 and MaxStrikeCount = 2. The handler will react to single and double taps.

Step 2: Add a Timer object to the component and configure its properties Begin = 250 and Period = 0. The value 250 determines the delay to defer the processing of the tap event. It corresponds to the global setting CursorSequelDelay found in the Application component. The timer delay should be >= the global setting.

Step 3: Connect the Simple Touch Handler so it starts and stops the Timer. For this purpose assign the timer's slot method StartTimer to the Handler's property OnRelease. Assign the slot method StopTimer to the property OnPress. Following figure demonstrates the connection:

Step 4: Finally add a slot method to the GUI component. Assign the slot method to the Timer's property OnTrigger.

With these steps, each time the user taps within the Touch Handler's area, the Timer is restarted. If the user has finished the interaction (e.g. after a single tap), the Timer expires and triggers the Slot method (step 4). Within the slot method you can evaluate now the variables of the Touch handler. For example, you can check whether the user has single or double tapped the Handler:

Step 5: Implement the Slot method to distinguish single/double taps:

Does it help you further?

Best regards

Paul Banach

by
Your solution works very well- Thank you Paul!

Embedded Wizard Website | Privacy Policy | Imprint

...