Long Press Event?

How can you detect and run an event on the long press of a button?

For example, holding the left click button for 2 seconds to bring up a context menu or something…

Any ideas?

On Press -> start timer.
If timer >= 2 -> do stuff.
On Release -> stop timer.

How about a 2 seconds timer that starts when the left-click is pressed. When time elapses simply execute the event and bring up a context menu in this case.
When left-click is released stop and clear the timer so if it is held for less than 2 seconds nothing will happen. :wink:

EDIT. Always late ;D

Also you could try something like this:
Create a new bool variable and call it **Interrupted **.

  • On left click pressed event Set **Interrupted **to **false **-> retriggerable delay (2 sec) → and create branch with **Interrupted → **on **false – **do stuff
  • On released left click Set **Interrupted **to true.