Hover delay?

D

David Veeneman

I want to introduce a one-second delay into the MouseHover event of a label.
In other words, I want the user to have to hover over a label for one second
before the label's MouseHover event triggers a response from the
application.

Here's what I've got so far:

-- Add a timer control and a bolean DoAction flag to the form.

-- Set DoAction flag to false and the timer for a one second interval.

-- Start the timer when the label's mouseEnter event fires.

-- When the label's MouseHover event fires, exit the event handler as long
as the DoAction flag is false.

-- When the timer fires it's interval event, set the DoAction flag to true.

The next MouseHover event will trigger the response to that event.

This approach seems more complicated than it needs to be. Is there a simpler
way to accomplish the same thing?

Thanks in advance.
 
K

Kevin Frey

So you keep getting MouseHover events as long as the mouse is hovering (as
opposed to just getting one MouseHover event)? I'm not intimately familiar
with how that event is fired, hence my question.

If you are getting multiple events, why bother with the timer at all. Why
not just use something like GetTickCount( ) (I'm referring to Win32 API -
whatever the c# equivalent is) and check if more than X milliseconds have
elapsed.

The timer here seems superfluous since I don't believe you need the
asynchronicity that the timer gives you.

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top