[OpenLayers-Users] Disabling right-click during DrawFeature of
a polygon
Andreas Hocevar
ahocevar at opengeo.org
Sat Nov 21 04:24:49 EST 2009
Hi,
the easiest way to do what you want is to make sure that your
right-click handler is registered before the draw handler. Then, in your
right-click handler, you have to stop the event from propagating, e.g. using
OpenLayers.Event.stop();
Regards,
Andreas.
Harry Lam wrote:
> In my map, I have added a OpenLayers.Control.DrawFeature(vectorLayer,
> OpenLayers.Handler.Polygon) control for drawing a polygon.
>
> The polygon gets drawn for both left clicks and right clicks on the map.
>
> How can I remove the right-click functionality? I ask because I
> already have other code to pull up a custom context menu on
> right-click. What occurs presently is that both the menu and the next
> polygon point appear at the same time. So while not an error per se,
> it is distracting and counter-intuitive.
>
> The Polygon handler inherits from the Path handler which contains a
>
> mousedown: function(evt) { ... }
>
> function that I assume is the driver for drawing the polygon. Am I
> forced to add custom code in here to disable my right-clicks? (I
> would prefer not to mess with the internal JS files if there are
> alternative methods.)
>
> Meanwhile, the OpenLayers.Control.Navigation control (added by default
> to most maps) has a handleRightClicks property that is *false* by
> default. So I don't think my solution is there...
>
> Any help or advice is appreciated!
>
> --Harry L.
> mr.harry.lam at gmail.com <mailto:mr.harry.lam at gmail.com>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list