Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Postpone the MouseOver event.

    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.

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Can you post all of the code so I can see? I have ideas but need to see what you have.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #5
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •