Mouse movement while a button is pressed

J

Jeroni Paul

<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.
 
J

Janwillem Borleffs

Jeroni Paul said:
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
 
J

Jeroni Paul

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.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top