onmousedown and onmouseup while dragging: What am I doing wrong?

C

coolsti

I am trying to let the user drag a rectangle over an image, which will
then let the user zoom in on the dragged area. However, I am doing
something wrong in implementing the onmousedown and onmouseup events.

Everything is very simple so far. I just defined an onMouseDown event to
record the event's x and y locations as the starting point, and an
onMouseUp event to record the x and y of the end point, and this function
gives me the results of both in an alert box.

The problem is, that the OnMouseUp event does not get fired if I move the
mouse while holding the left button down. This only works if I click down
and then up at the same point, which is not what I want.

What could be wrong? Why does the browser not recognize the mouse up when
the mouse is moved while holding the left button down? How do I fix this?

Thanks,
Steve
 
C

coolsti

On Sun, 15 May 2005 20:17:23 +0200, coolsti wrote:

I guess I can answer my own question. I found out the problem.

It seems that when doing this trick over an image, I need to tell the
browser not to do its standard thing when the mouse is moved with the left
button pressed. To do this I needed to have
onMouseMove="myFunction();return false;" instead of what I had before,
onMouseMove="myFunction()"

Otherwise the browser cancelled the mouse event after moving the mouse
more than xxx pixels.

steve
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top