Ticket #1359: RightMouseV2.patch
| File RightMouseV2.patch, 5.6 kB (added by itbeyond, 3 months ago) |
|---|
-
lib/OpenLayers/Control/Navigation.js
old new 105 105 */ 106 106 draw: function() { 107 107 this.handlers.click = new OpenLayers.Handler.Click(this, 108 { 'dblclick': this.defaultDblClick },109 {108 { 'dblclick': this.defaultDblClick, 'dblrightclick': this.defaultDblRightClick }, 109 { 110 110 'double': true, 111 111 'stopDouble': true 112 112 }); … … 133 133 }, 134 134 135 135 /** 136 * Method: defaultRightDblClick 137 * 138 * Parameters: 139 * evt - {Event} 140 */ 141 defaultDblRightClick: function (evt) { 142 var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 143 this.map.setCenter(newCenter, this.map.zoom - 1); 144 }, 145 146 /** 136 147 * Method: wheelChange 137 148 * 138 149 * Parameters: -
lib/OpenLayers/Events.js
old new 105 105 }, 106 106 107 107 /** 108 * Method: isRightClick 109 * Determine whether event was caused by a right mouse click. 110 * 111 * Parameters: 112 * event - {Event} 113 * 114 * Returns: 115 * {Boolean} 116 */ 117 isRightClick: function(event) { 118 return (((event.which) && (event.which == 3)) || 119 ((event.button) && (event.button == 2))); 120 }, 121 122 /** 108 123 * Method: stop 109 124 * Stops an event from propagating. 110 125 * … … 352 367 BROWSER_EVENTS: [ 353 368 "mouseover", "mouseout", 354 369 "mousedown", "mouseup", "mousemove", 355 "click", "dblclick", 370 "click", "dblclick", "rightclick", "dblrightclick", 356 371 "resize", "focus", "blur" 357 372 ], 358 373 -
lib/OpenLayers/Handler/Click.js
old new 90 90 down: null, 91 91 92 92 /** 93 * Property: rightclickTimerId 94 * {Number} The id of the right mouse timeout waiting to clear the <delayedEvent>. 95 */ 96 rightclickTimerId: null, 97 98 /** 93 99 * Constructor: OpenLayers.Handler.Click 94 100 * Create a new click handler. 95 101 * … … 125 131 * {Boolean} Continue propagating this event. 126 132 */ 127 133 mousedown: null, 134 /** 135 * Method: mouseup 136 * Handle mouseup. Installed to support collection of right mouse events 137 * 138 * Returns: 139 * {Boolean} Continue propagating this event. 140 */ 141 mouseup: function (evt) { 142 var propagate = true; 143 // Collect right mouse clicks from the mouseup 144 // IE - ignores the second right click in mousedown so using mouseup instead 145 if (this.checkModifiers(evt) && OpenLayers.Event.isRightClick(evt)) { 146 return this.rightclick(evt); 147 } 148 return propagate; 149 }, 128 150 129 151 /** 152 * Method: rightclick 153 * Handle rightclick. For a dblrightclick, we get two clicks 154 * so we need to always register for dblrightclick to properly handle single clicks. 155 * 156 * Returns: 157 * {Boolean} Continue propagating this event. 158 */ 159 rightclick: function(evt) { 160 if(this.passesTolerance(evt)) { 161 if(this.rightclickTimerId != null) { 162 // Second click received before timeout this must be a double click 163 this.clearTimer(); 164 this.callback('dblrightclick', [evt]); 165 return !this.stopDouble; 166 } else { 167 // set the rightclickTimerId, send evt only if double is true else trigger single 168 var clickEvent = this.double ? 169 OpenLayers.Util.extend({}, evt) : this.callback('rightclick', [evt]); 170 this.rightclickTimerId = window.setTimeout( 171 OpenLayers.Function.bind(this.delayedRightCall, this, clickEvent), 172 this.delay ); 173 } 174 } 175 return !this.stopSingle; 176 }, 177 178 /** 179 * Method: delayedRightCall 180 * Sets <rightclickTimerId> to null. And optionally triggers the rightclick callback if 181 * evt is set. 182 */ 183 delayedRightCall: function(evt) { 184 this.rightclickTimerId = null; 185 if(evt) { 186 this.callback('rightclick', [evt]); 187 } 188 return !this.stopSingle; 189 }, 190 191 /** 130 192 * Method: dblclick 131 193 * Handle dblclick. For a dblclick, we get two clicks in some browsers 132 194 * (FF) and one in others (IE). So we need to always register for -
lib/OpenLayers/Map.js
old new 421 421 this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1; 422 422 423 423 this.viewPortDiv.appendChild(this.layerContainerDiv); 424 424 425 // disable right mouse context menu for support of right click events 426 this.div.oncontextmenu = function () { return false;}; 427 425 428 this.events = new OpenLayers.Events(this, 426 429 this.div, 427 430 this.EVENT_TYPES,
