From 601a6c8376dce720ef7287d0df28bfe2196ff71e Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 15 Sep 2006 20:20:59 +0000 Subject: [PATCH] was able to reproduce the wierd clicking bug jrf found. it was happening because the mouseup was not being properly handled by the toolbar buttons. this is taken care of. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1477 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/MouseToolbar.js | 56 +++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Control/MouseToolbar.js b/lib/OpenLayers/Control/MouseToolbar.js index 7c8dd6042c..7939b3300d 100644 --- a/lib/OpenLayers/Control/MouseToolbar.js +++ b/lib/OpenLayers/Control/MouseToolbar.js @@ -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, @@ -63,9 +66,9 @@ OpenLayers.Control.MouseToolbar.prototype = btn.activeImgLocation = activeImgLocation; btn.events = new OpenLayers.Events(this, btn, null, true); - btn.events.register("mousedown", this, this.buttonClick); - btn.events.register("dblclick", this, - OpenLayers.Util.safeStopPropagation); + 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 @@ -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,6 +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)) { + 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;