Pullup fixes to mouse controls since 2.1-rc1, along with a fix for

zooming. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1481 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-09-18 18:48:29 +00:00
parent 130e527702
commit 5f8dc06823
7 changed files with 83 additions and 32 deletions

View File

@@ -141,9 +141,12 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt
*/
defaultMouseOut: function (evt) {
if (this.mouseDragStart != null
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt);
if (this.mouseDragStart != null &&
OpenLayers.Util.mouseLeft(evt, this.map.div)) {
if (this.zoomBox) {
this.removeZoomBox();
}
this.mouseDragStart = null;
}
},
@@ -188,9 +191,16 @@ OpenLayers.Control.MouseDefaults.prototype =
(end.lat)
), this.map.getZoom() + 1);
}
this.map.viewPortDiv.removeChild(this.zoomBox);
this.zoomBox = null;
}
this.removeZoomBox();
}
},
/**
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeZoomBox: function() {
this.map.viewPortDiv.removeChild(this.zoomBox);
this.zoomBox = null;
},

View File

@@ -21,6 +21,9 @@ OpenLayers.Control.MouseToolbar.prototype =
direction: "vertical",
/** @type String */
buttonClicked: null,
initialize: function(position, direction) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,
@@ -62,10 +65,10 @@ OpenLayers.Control.MouseToolbar.prototype =
btn.imgLocation = imgLocation;
btn.activeImgLocation = activeImgLocation;
btn.events = new OpenLayers.Events(this, btn);
btn.events.register("mousedown", this, this.buttonClick);
btn.events.register("mouseup", this, Event.stop);
btn.events.register("click", this, Event.stop);
btn.events = new OpenLayers.Events(this, btn, null, true);
btn.events.register("mousedown", this, this.buttonDown);
btn.events.register("mouseup", this, this.buttonUp);
btn.events.register("dblclick", this, Event.stop);
btn.action = id;
btn.title = title;
btn.alt = title;
@@ -76,11 +79,28 @@ OpenLayers.Control.MouseToolbar.prototype =
return btn;
},
buttonClick: function(evt) {
/**
* @param {Event} evt
*/
buttonDown: function(evt) {
if (!Event.isLeftClick(evt)) return;
this.switchModeTo(evt.element.action);
this.buttonClicked = evt.element.action;
Event.stop(evt);
},
/**
* @param {Event} evt
*/
buttonUp: function(evt) {
if (!Event.isLeftClick(evt)) return;
if (this.buttonClicked != null) {
if (this.buttonClicked == evt.element.action) {
this.switchModeTo(evt.element.action);
}
Event.stop(evt);
this.buttonClicked = null;
}
},
/**
* @param {Event} evt
@@ -89,7 +109,7 @@ OpenLayers.Control.MouseToolbar.prototype =
this.switchModeTo("pan");
this.performedDrag = false;
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 2);
this.map.setCenter(newCenter, this.map.zoom + 1);
Event.stop(evt);
return false;
},
@@ -179,6 +199,8 @@ OpenLayers.Control.MouseToolbar.prototype =
switchModeTo: function(mode) {
if (mode != this.mode) {
if (this.mode && this.buttons[this.mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
}
@@ -195,6 +217,15 @@ OpenLayers.Control.MouseToolbar.prototype =
if (this.buttons[mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
}
switch (this.mode) {
case "zoombox":
this.map.div.style.cursor = "crosshair";
break;
default:
this.map.div.style.cursor = "default";
break;
}
}
},
@@ -254,12 +285,21 @@ OpenLayers.Control.MouseToolbar.prototype =
this.map.div.style.cursor = "default";
},
/**
* @param {Event} evt
*/
defaultMouseOut: function (evt) {
if (this.mouseDragStart != null
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
this.defaultMouseUp(evt);
if (this.zoomBox) {
this.removeZoomBox();
if (this.startViaKeyboard) this.leaveMode();
}
this.mouseDragStart = null;
this.map.div.style.cursor = "default";
}
},
defaultClick: function (evt) {
if (this.performedDrag) {
this.performedDrag = false;

View File

@@ -86,7 +86,7 @@ OpenLayers.Control.PanZoomBar.prototype =
"absolute");
this.slider = slider;
this.sliderEvents = new OpenLayers.Events(this, slider);
this.sliderEvents = new OpenLayers.Events(this, slider, null, true);
this.sliderEvents.register("mousedown", this, this.zoomBarDown);
this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
this.sliderEvents.register("mouseup", this, this.zoomBarUp);
@@ -116,7 +116,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.zoombarDiv = div;
this.divEvents = new OpenLayers.Events(this, div);
this.divEvents = new OpenLayers.Events(this, div, null, true);
this.divEvents.register("mousedown", this, this.divClick);
this.divEvents.register("mousemove", this, this.passEventToSlider);
this.divEvents.register("dblclick", this, this.doubleClick);