[OpenLayers-Users] right click

Andrew Nowrot andrew.nowrot at gmail.com
Mon Oct 17 09:17:45 EDT 2011


Hi

Is there a way to disable point drawing on right mouse click. Now I
can draw points on both left and right mouse click, but in my system I
want to have context menu on right click.
Below is the piece of code which I am using

-- to register control:
....
ctrls = {
           redlayer: new OpenLayers.Control.DrawFeature(redlayer,
OpenLayers.Handler.Point, {callbacks: {"done": onFeatureAdd}})
          }
....

-- to add context menu:
map.div.oncontextmenu = function noContextMenu(e) {
            if (OpenLayers.Event.isRightClick(e)){
                    ctrls['redlayer'].deactivate();
            }
            return false;
        }

So now when I am "rightclicking" everything works as expected but only
under FireFox and Chrome on Ubunt (basically Linux). Under FF and
Chrome on Windows XP and 7 when I am rightclicking I am still able to
draw a point. The same thing is with drawing lines (I am also
assuming that polygon is causing the same issues)
Is it possible to add DrawFeature only with left click option.

Best Regards
Andrew


More information about the Users mailing list