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?
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.
EDIT. Always late ;D
Also you could try something like this:
Create a new bool variable and call it **Interrupted **.