Fixed MouseDefaults so that click doesn't fire immediately after drag. This needs to be tested in IE.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@571 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Schuyler Erle
2006-06-12 00:32:48 +00:00
parent 55937eeb1f
commit 2f9c7dfbd3

View File

@@ -3,11 +3,14 @@ OpenLayers.Control.MouseDefaults = Class.create();
OpenLayers.Control.MouseDefaults.prototype = OpenLayers.Control.MouseDefaults.prototype =
Object.extend( new OpenLayers.Control(), { Object.extend( new OpenLayers.Control(), {
performedDrag: false,
initialize: function() { initialize: function() {
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
}, },
draw: function() { draw: function() {
this.map.events.register( "click", this, this.defaultClick );
this.map.events.register( "dblclick", this, this.defaultDblClick ); this.map.events.register( "dblclick", this, this.defaultDblClick );
this.map.events.register( "mousedown", this, this.defaultMouseDown ); this.map.events.register( "mousedown", this, this.defaultMouseDown );
this.map.events.register( "mouseup", this, this.defaultMouseUp ); this.map.events.register( "mouseup", this, this.defaultMouseUp );
@@ -15,6 +18,12 @@ OpenLayers.Control.MouseDefaults.prototype =
this.map.events.register( "mouseout", this, this.defaultMouseOut ); this.map.events.register( "mouseout", this, this.defaultMouseOut );
}, },
defaultClick: function (evt) {
var notAfterDrag = !this.performedDrag;
this.performedDrag = false;
return notAfterDrag;
},
/** /**
* @param {Event} evt * @param {Event} evt
*/ */
@@ -28,6 +37,7 @@ OpenLayers.Control.MouseDefaults.prototype =
*/ */
defaultMouseDown: function (evt) { defaultMouseDown: function (evt) {
this.mouseDragStart = evt.xy.copyOf(); this.mouseDragStart = evt.xy.copyOf();
this.performedDrag = false;
if (evt.shiftKey) { if (evt.shiftKey) {
this.map.div.style.cursor = "crosshair"; this.map.div.style.cursor = "crosshair";
this.zoomBox = OpenLayers.Util.createDiv('zoomBox', this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
@@ -41,8 +51,6 @@ OpenLayers.Control.MouseDefaults.prototype =
this.zoomBox.style.opacity = "0.50"; this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox); this.map.viewPortDiv.appendChild(this.zoomBox);
} else {
this.map.div.style.cursor = "move";
} }
Event.stop(evt); Event.stop(evt);
}, },
@@ -72,7 +80,9 @@ OpenLayers.Control.MouseDefaults.prototype =
var newCenter = this.map.getLonLatFromScreenPx( newXY ); var newCenter = this.map.getLonLatFromScreenPx( newXY );
this.map.setCenter(newCenter, null, true); this.map.setCenter(newCenter, null, true);
this.mouseDragStart = evt.xy.copyOf(); this.mouseDragStart = evt.xy.copyOf();
this.map.div.style.cursor = "move";
} }
this.performedDrag = true;
} }
}, },