Mouse movement while a button is pressed

Discussion in 'Javascript' started by Jeroni Paul, Sep 4, 2003.

  1. Jeroni Paul

    Jeroni Paul Guest

    <BODY onmousemove="return false;" oncontextmenu="return false;">
    <IMG src="button.gif" onmouseover="this.src='down.gif'"
    onmouseout="this.src='button.gif'">
    </BODY>

    This simple example shows where my problem is. It works fine when all
    mouse buttons are released, and also if a button is pressed outside
    the image. But if a button is pressed inside the picture it'll not
    call onmouseout when the mouse is brought outside the picture. The
    worst is it'll never call it, leaving the button stuck pressed forever
    until mouse is moved over it again.
    I just noticed if I place the picture inside an A tag it does work
    fine then, but I don't need an A element here. Moreover, this fix
    appears to work only for IE6, IE4 still doesn't work properly.
    I'm asking if there's some other way to correct this. I'm also making
    this compatible with Netscape 4.5, and the presence of an A element
    changes the event.target.
    The fact is I can't seem to disable the default drag'n drop of IE with
    pictures. Netscape 4.5 appears to work perfectly. By placing
    onmousemove="return false;" in BODY I aboid the cursor change in IE
    but nothing else.

    Thank you for any idea.
    Jeroni Paul, Sep 4, 2003
    #1
    1. Advertising

  2. "Jeroni Paul" <> schreef in bericht
    news:...
    >
    > This simple example shows where my problem is. It works fine when all
    > mouse buttons are released, and also if a button is pressed outside
    > the image. But if a button is pressed inside the picture it'll not
    > call onmouseout when the mouse is brought outside the picture. The
    > worst is it'll never call it, leaving the button stuck pressed forever
    > until mouse is moved over it again.


    Try it with the onmousedown/onmouseup event handlers:

    <IMG src="button"
    onmousedown="src='down.gif'"
    onmouseup="src='up.gif'"
    >


    Alternatively, you can throw in the onmouseover/out handlers as well...

    JW
    Janwillem Borleffs, Sep 4, 2003
    #2
    1. Advertising

  3. Jeroni Paul

    Jeroni Paul Guest

    Janwillem Borleffs said:
    > Try it with the onmousedown/onmouseup event handlers:
    >
    > <IMG src="button"
    > onmousedown="src='down.gif'"
    > onmouseup="src='up.gif'"
    > >

    >
    > Alternatively, you can throw in the onmouseover/out handlers as
    > well...
    >
    > JW


    Hi, thank you for replying. This fixes the button stuck issue :)
    but I'm more interested in fixing the main problem, that is to be able to
    change the pictures while the button is pressed by running mouse cursor over
    the pictures. Or at least, to know that I'm trying to do something
    impossible :)
    In Netscape, I'm handling the events using the window.captureEvents, and
    with the IMG element it works great. In IE I use a similar approach by
    taking the events from document.onxxxxxx, given that every event bubbles to
    the top. However no matter how I do the handling, it doesn't work.

    It seems the only solution is to place an <A href="#"> element so that IE
    forgets its actions with pictures. It still doesn't work in IE4, but maybe
    it's impossible.
    Jeroni Paul, Sep 5, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Claus Atzenbeck
    Replies:
    1
    Views:
    1,064
    Claus Atzenbeck
    Nov 26, 2004
  2. Luc The Perverse

    Question! Capture Mouse Movement :)

    Luc The Perverse, Oct 24, 2005, in forum: Java
    Replies:
    16
    Views:
    3,979
    Roedy Green
    Oct 30, 2005
  3. TogaKangaroo
    Replies:
    2
    Views:
    2,068
    Ioannis Vranos
    Feb 12, 2005
  4. Rune
    Replies:
    6
    Views:
    1,230
    Richie Hindle
    Jan 29, 2004
  5. marss
    Replies:
    4
    Views:
    128
Loading...

Share This Page