[OpenLayers-Users] Handling double click

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Mon May 19 07:51:00 EDT 2008


I have a map where several features have links attached.
A script checks the current cursor position against the server to 
determine if there is a link at the current location.
If there is, the cursor changes to the hand cursor.
This all works fine.

Regardless of what tool the user has, I would like to intercept a 
double-click.
I can do that with the doubleclick handler:
doubleClick = new OpenLayers.Handler.DoubleClick(this, {dblclick: 
this.OnDoubleClick}, {single: false, 'double': true, stopSingle: false, 
stopDouble: true});
doubleClick.activate();

And it works, but the original tool also gets activated.
Ea., if the zoom tool is activated, it zooms twice for a double click, 
as well as activating the custom doubleclick handler.

Is there any way to achieve this?

It seems that the "click" event is fired before the "doubleclick" event 
happens, so it is difficult to filter the click.
My handler looks like this:

    OnDoubleClick: function(evt)
    {  
        if (this.activeLink != null)
        {
            window.open(this.activeLink, this.target);
            OpenLayers.Event.stop(evt);
            return false;
        }
        else
            return true;
    },

The "return false" does not prevent the click events from occuring.
Stopping the single click events makes the current tool useless.

-- 
Regards, Kenneth Skovhede, GEOGRAF A/S





More information about the Users mailing list