View Full Version : Postpone the MouseOver event.

04-22-2009, 02:01 PM
Hi, I was wondering if anyone could help me out of this. I have spent much of the time for the following issue.
I have a button that opens up a drop down list when MOUSE_OVER event occurs. To delay the opening of a drop down list I have used setTimeout function in the event listener so that it is called after 1 sec.
setTimeout(functionToBeCalled, 1000, event);
In this case if a user moves mouse over that button the event gets fired after 1000ms.
But if user unknowingly moves the mouse and if it happens to move across that button the event gets fired no matter where the mouse is at present.
What I want is the event should be fired only if the Mouse is over that button for 1000ms. If I move away the mouse, say, within 500 ms from that button that event shouldn't be fired.
Any help would be greatly appreciated.

04-22-2009, 02:32 PM
I would suggest adding a conditional to the functionToBeCalled, which checks if the mouse is still over or not before firing.

Just a simple hitTest would do I'd think.

04-22-2009, 02:59 PM
And how can we do that i.e; add condition to check if the mouse is really over or not in the function 'functionToBeCalled'. Because I have tried it by using this:-
if(event.currentTarget.name == "buttonName") {
setTimeout(functionToBeCalled, 1000, event);
But this too didn't work.

04-22-2009, 03:27 PM
Can you post all of the code so I can see? I have ideas but need to see what you have.

04-24-2009, 10:47 AM
Thanks for your support. I have managed to solve it. It was just a logical problem.
I solved it by defining other function that would set a Boolean variable to true or false depending on MouseOver or MouseOut events.
I used value of that Boolean variable as a condition to call the setTimeout function.
Thanks again.