onmouseup not recognized if mouse moves
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: onmouseup not recognized if mouse moves

  1. #1
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,448

    onmouseup not recognized if mouse moves

    I'm writing a tracing program in JS to drawline from where the mouse is pressed, held while its moved and then released. The onmouseup function is NOT called when the mouse is moved away from the location where it was pressed. It is called if the up is at the same location as the down. A workaround I've found is for the mousemove function to exit when a key (control or alt) is pressed as that is recorded in the event property.
    Is there a way for mouseup to be recognized when the mouse has moved from the down location?

    The tracing is over the top of a large image of a map. The purpose of the program is to measure distances on the map for various trips.

    Thanks,
    Norm
    Norm

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,881

    Re: onmouseup not recognized if mouse moves

    I would suggest registering the mouse events with the document object.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Aug 2005
    Location
    Milwaukee, WI
    Posts
    55

    Re: onmouseup not recognized if mouse moves

    By which Peej means to do this: http://www.quirksmode.org/js/events_tradmod.html
    Meddle not in the affairs of dragons, human, for thou art crunchy and taste good with ketchup.

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,881

    Re: onmouseup not recognized if mouse moves

    Well, it's slightly more than just that. Remember to use document.addEventListener for non-IE browsers and document.attachEvent for Internet Explorer.
    Last edited by PeejAvery; February 4th, 2009 at 03:28 PM. Reason: Fixed BB code.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,448

    Re: onmouseup not recognized if mouse moves

    Thanks.
    I was also having a problem with the design. Holding the mouse down while moving it was being interpreted as a drag. I changed the design to use a mousedown to start, mousemove to trace and another mousedown to end the trace. It's now working.

    Norm
    Norm

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center