Add support in OL for right-click capturing, including dbl-right-clicks (for zooming out in navigation control). Thanks to David Martin for this nice patch and the great 8 foot austrian for his review (Closes #1359)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7872 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -47,6 +47,12 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Boolean} Whether the mousewheel should zoom the map
|
||||
*/
|
||||
zoomWheelEnabled: true,
|
||||
|
||||
/**
|
||||
* APIProperty: handleRightClicks
|
||||
* {Boolean} Whether or not to handle right clicks. Default is false.
|
||||
*/
|
||||
handleRightClicks: true,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.Navigation
|
||||
@@ -110,12 +116,22 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: draw
|
||||
*/
|
||||
draw: function() {
|
||||
this.handlers.click = new OpenLayers.Handler.Click(this,
|
||||
{ 'dblclick': this.defaultDblClick },
|
||||
{
|
||||
'double': true,
|
||||
'stopDouble': true
|
||||
});
|
||||
// disable right mouse context menu for support of right click events
|
||||
if (this.handleRightClicks) {
|
||||
this.map.div.oncontextmenu = function () { return false;};
|
||||
}
|
||||
|
||||
var clickCallbacks = {
|
||||
'dblclick': this.defaultDblClick,
|
||||
'dblrightclick': this.defaultDblRightClick
|
||||
};
|
||||
var clickOptions = {
|
||||
'double': true,
|
||||
'stopDouble': true
|
||||
};
|
||||
this.handlers.click = new OpenLayers.Handler.Click(
|
||||
this, clickCallbacks, clickOptions
|
||||
);
|
||||
this.dragPan = new OpenLayers.Control.DragPan(
|
||||
OpenLayers.Util.extend({map: this.map}, this.dragPanOptions)
|
||||
);
|
||||
@@ -140,6 +156,17 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultRightDblClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultDblRightClick: function (evt) {
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom - 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: wheelChange
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user