Resident Evil
Resident Evil

Reputation: 3

Event listener for pushing and holding a button

Looking for a type of event listener that activates when user push and holds a button and another EL that listens for user not pushing button anymore.

If it's not very clear what I want, then let me put it like this: I have a time picker app with increment/decrement buttons it is boring to click 40 times to get to say minute 45, so I want something that speeds up when user pushes instead of single click.

Note: I have seen on-mousedown and leave they did not work out for me because first of all I want user to push second of all the the mouse-leave works only if you move your mouse outside of button area witch is not convenient.

I also tried mouseon and mouseleave it is not what I want

Upvotes: 0

Views: 228

Answers (1)

CBFT
CBFT

Reputation: 302

You will want to use MouseDown, MouseLeave, and MouseUp events.

Start a Timer when they press the MouseDown. When the Timer.Elapsed event hits increment the value. You will also want to trigger the event immediately to account for clicks.

Both MouseLeave and MouseUp events should stop and dispose of the Timer + reset any variables.

You could also use an int TimerCount and when that value hits 5 start incrementing the value by a larger amount.

Upvotes: 0

Related Questions