[OpenLayers-Dev] contextmenu

pdecker paulad at rmi.net
Wed Feb 6 13:15:05 EST 2008


I want to have a custom context menu popup over a tiled image.

I have tried to make the changes to Events.js and MouseDefaults.js as
suggested in another thread.  Its not working for me maybe because I have
the mouse wheel and double click functionality removed from my application. 
I removed it by coding the following:

// Redefine the OpenLayers.Control.Navigation.activate() method.
    var nav = new OpenLayers.Control.Navigation();
    nav.activate = function() {
        return OpenLayers.Control.prototype.activate.apply(this,arguments);
// Redefine the OpenLayers.Control.Navigation.draw() method.            
    nav.draw = function() {
        this.dragPan = new OpenLayers.Control.DragPan({map: this.map});
        this.zoomBox = new OpenLayers.Control.ZoomBox(
        {map: this.map, keyMask: OpenLayers.Handler.MOD_SHIFT});

The thread suggested to add the following method to Events.js:

    isRightClick: function(event) {
        return (((event.which) && (event.which == 2)) ||
                ((event.button) && (event.button == 2)));

and to modify the defaultMouseDown method of MouseDefaults.js:

    defaultMouseDown: function (evt) {
    	if (OpenLayers.Event.isRightClick(evt)){
    		OpenLayers.Console.warn("Right button click");
The above message never appeared on the console after a right button click.

I have also tried setting document.oncontextmenu with a method of my own. 
This worked, but the left mouse button click did not work.  The left mouse
button click was needed to delete the popup menu.

Is there a different way to deactivate the mouse wheel and double click? 
Are there any suggestions on how to get the custom context menu working?


View this message in context: http://www.nabble.com/contextmenu-tp15309685p15309685.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.

More information about the Dev mailing list