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

@@ -12,7 +12,6 @@ of different layers.
clone() -- {OpenLayers.Layer} -- create a clone of the layer.
setName({String|name}) -- none -- Set the name of the layer to something different.
moveTo({OpenLayers.Bounds|bounds}, {Boolean|zoomChanged}) -- none -- Not implemented here, but the general function called on dragging or setCenter, to move the Layer to a new geographic location.
reproject() -- none -- Subclassed by vector layers to redraw vectors when base layer changes.
setMap(map) -- none -- Set the map property of the layer. Also set the parameters which are inherited from the map.
getVisibility() -- {Boolean} -- Return true or false based on visibility of the layer.
setVisibility({Boolean|visible}) -- none -- Set the layer visibility, and trigger the appropriate events.

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);

View File

@@ -37,11 +37,14 @@ OpenLayers.Events.prototype = {
* is being added
* @param {DOMElement} element A dom element to respond to browser events
* @param {Array} eventTypes Array of custom application events
* @param {Boolean} fallThrough Allow events to fall through after these
* have been handled?
*/
initialize: function (object, element, eventTypes) {
initialize: function (object, element, eventTypes, fallThrough) {
this.object = object;
this.element = element;
this.eventTypes = eventTypes;
this.fallThrough = fallThrough;
this.listeners = new Object();
// if eventTypes is specified, create a listeners list for each
@@ -176,7 +179,9 @@ OpenLayers.Events.prototype = {
}
}
// don't fall through to other DOM elements
Event.stop(evt);
if (!this.fallThrough) {
Event.stop(evt);
}
}
},

View File

@@ -322,7 +322,6 @@ OpenLayers.Layer.prototype = {
this.resolutions.push(this.maxResolution / Math.pow(2, i));
}
}
this.resolutions = this.resolutions.sort().reverse();
},
/**

View File

@@ -250,18 +250,16 @@ OpenLayers.Popup.prototype = {
* hyperlinks or drag-selecting text.
*/
registerEvents:function() {
Event.observe(this.div, "mousedown",
this.onmousedown.bindAsEventListener(this));
Event.observe(this.div, "mousemove",
this.onmousemove.bindAsEventListener(this));
Event.observe(this.div, "mouseup",
this.onmouseup.bindAsEventListener(this));
Event.observe(this.div, "click",
OpenLayers.Util.safeStopPropagation);
Event.observe(this.div, "mouseout",
this.onmouseout.bindAsEventListener(this));
Event.observe(this.div, "dblclick",
OpenLayers.Util.safeStopPropagation);
this.events = new OpenLayers.Events(this, this.div, null, true);
this.events.register("mousedown", this, this.onmousedown);
this.events.register("mousemove", this, this.onmousemove);
this.events.register("mouseup", this, this.onmouseup);
this.events.register("click", this,
OpenLayers.Util.safeStopPropagation);
this.events.register("mouseout", this, this.onmouseout);
this.events.register("dblclick", this,
OpenLayers.Util.safeStopPropagation);
},
/** When mouse goes down within the popup, make a note of