[OpenLayers-Users] Having problems with custom mouse event handlers
Nick Whitelegg
nick at hogweed.org
Mon Aug 28 17:32:46 CDT 2006
Hello everyone,
I am trying to develop custom mouse event handling code so that when the user
drags on the map in a particular mode, the distance corresponding to the drag
is calculated and displayed. The mouse down handling code is something like
this:
function mouseDownHandler(e)
{
if(mode==3)
{
dragging=true;
return false;
}
else
map.controls[0].defaultMouseDown(e);
// Four attempts at preventing the drag and drop thing happening
e.preventDefault();
document.onselectstart = function () { return false; }
Event.stop(e);
return false;
}
In other words, if the mode is 3, my custom code kicks in, otherwise the
default mouse handling code is called, resulting in the map moving in
response to a drag.
The problem is this. Despite attempting four different ways of preventing it,
the e.preventDefault() and return false (which I was aware of before
OpenLayers) and the onselectstart and Event.stop (which I found by examining
the OpenLayers code), I can't prevent the "drag and drop" action occurring
(Firefox 1.5 on Linux). This has the knock on effect of preventing a mouse
up event being registered when the user stops dragging/
Can anyone give any guidance as to what I'm doing wrong here? Previously to
prevent the "drag and drop" thing happening, the simple "return false" has
worked.
Full code at http://nick.dev.openstreetmap.org/openlayers/main.js
Thanks,
Nick
More information about the Users
mailing list