[OpenLayers-Users] Using RightClick event as exposed in 2.7
David Martin
David at itbeyond.com.au
Wed Oct 1 01:39:22 EDT 2008
Hi all,
I was the patch provider for the right click mods however I cannot for
the life of me work out what I am doing wrong trying to use the single
rightclick event. Below is the Control.Click code I am using the trigger
(left click) function works fine but the righttrigger (right click)
never fires. Can someone please tell me what I am doing wrong?
I have registered the rightclick functions in the navigation control
using:
Placemap.addControl(new
OpenLayers.Control.Navigation({'zoomWheelEnabled': false,
'handleRightClicks': true}));
Thus the context menu is disabled and double right click event perform
the zoom out function.
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {'single': true,'double':
false,'pixelTolerance': 0,'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, {'click':
this.trigger, 'rightclick': this.righttrigger}, this.handlerOptions);
},
trigger: function(e) {
PopupClose(null);
var clickpos =
Placemap.getLonLatFromViewPortPx(e.xy).transform(MapProj, DispProj);
var lstr=''; var olays = Placemap.getLayersBy('isBaseLayer',
false);
for(var i=0; i<olays.length; i++) {if (olays[i].visibility
&& olays[i].displayInLayerSwitcher) lstr += olays[i].name + '|';}
if (lstr.length > 0) { OpenLayers.Element.show('Reload');
var Zoom = Placemap.getZoom();
if (Zoom > 10) Zoom = 10;
var dist = parseInt((10 - Zoom) * 10);
if (dist == 0) dist=1;
url = 'Places/OutputPlaceGEORSS.aspx?x=' + clickpos.lon
+ '&y=' + clickpos.lat + '&d=' + dist + '&poistr=' + lstr.substring(0,
lstr.length-1);
var responseObj = new OpenLayers.Ajax.Request(url, {
method:'get', onComplete: function(transport){var response =
transport.responseText || 'no response text'; deserialize(response)},
onFailure: function(){ alert('Places get result failed...');
OpenLayers.Element.hide('Reload'); } });
}
},
righttrigger: function(e) {
// var clickpos =
Placemap.getLonLatFromViewPortPx(e.xy).transform(MapProj, DispProj);
alert('Right click');
}
});
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/20081001/ae34b921/attachment.html
More information about the Users
mailing list