[OpenLayers-Users] Using RightClick event as exposed in 2.7

David Martin David at itbeyond.com.au
Wed Mar 18 01:46:25 EDT 2009


List,

There are a few questions about right mouse support in OL2.7 I have just
installed a patch which corrects an issue with the dblrightclick event
that was causing some issues when trying to capture right mouse events.
The ticket is http://trac.openlayers.org/ticket/1995 - So if you want to
use right mouse events then install this patch and see the example cod
below which works as expected:

 

    OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
'handleRightClicks': true,

        defaultHandlerOptions: { 'single': true, 'double': true,
'stopSingle': false, 'stopDouble': false },

        initialize: function(options) {

            this.handlerOptions = OpenLayers.Util.extend({},
this.defaultHandlerOptions);

            OpenLayers.Control.prototype.initialize.apply(this,
arguments);

            this.handler = new OpenLayers.Handler.Click(this, {
'rightclick': this.righttrigger }, this.handlerOptions);

        },

        righttrigger: function(e) {

            alert('Right click');

        }

    });

Note that the Control must be configured to handleRightClicks and that
the double action in the defaultHandlerOptions must be true as the
single right mouse click event is triggered only if the code determines
that it is not a double click (a pain but required as the browsers do
not handle the right mouse well). I have used this code in the same
program as the navigation control as below: 

Map.addControl(new OpenLayers.Control.Navigation({ 'zoomWheelEnabled':
false, 'handleRightClicks': true }));

However you must install the patch first or wait till it is included and
released. Good luck.

Regards
David Martin
Managing Director
I.T. Beyond Pty Ltd

Postal:

PO BOX 967
HILLARYS WA 6923

Ph:

(08) 9403 3737 

Mobile:

0417 677 275 

Fax:

(08) 9403 3738

Skype:

itbeyond_david

________________________________

Check out our websites: www.ExplorOz.com <http://www.exploroz.com/>  and
www.itbeyond.com.au <http://www.itbeyond.com.au/> 

________________________________

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090318/80412eea/attachment.html


More information about the Users mailing list