diff --git a/lib/OpenLayers/Control/MouseToolbar.js b/lib/OpenLayers/Control/MouseToolbar.js index 08f0ffedf4..c686b52bf7 100644 --- a/lib/OpenLayers/Control/MouseToolbar.js +++ b/lib/OpenLayers/Control/MouseToolbar.js @@ -8,10 +8,14 @@ OpenLayers.Control.MouseToolbar.prototype = mode: null, buttons: null, + + direction: "vertical", - initialize: function() { + initialize: function(direction) { OpenLayers.Control.prototype.initialize.apply(this, arguments); - this.mode = null; + if (direction) { + this.direction = direction; + } }, draw: function() { @@ -22,9 +26,10 @@ OpenLayers.Control.MouseToolbar.prototype = this.map.events.register( "mouseup", this, this.defaultMouseUp ); this.map.events.register( "mousemove", this, this.defaultMouseMove ); this.map.events.register( "mouseout", this, this.defaultMouseOut ); - var sz = new OpenLayers.Size(18,18); + var sz = new OpenLayers.Size(28,28); var centered = new OpenLayers.Pixel(100, 20); - this._addButton("zoombox", "west-mini.png", "east-mini.png", centered, sz); + this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz); + this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", new OpenLayers.Pixel(100,47), sz); return this.div; }, @@ -42,7 +47,8 @@ OpenLayers.Control.MouseToolbar.prototype = btn.activeImgLocation = activeImgLocation; btn.events = new OpenLayers.Events(this, btn); - btn.events.register("click", this, this.buttonClick); + btn.events.register("mousedown", this, this.buttonClick); + btn.events.register("mouseup", this, this.stopAction); btn.action = id; btn.map = this.map; @@ -51,6 +57,10 @@ OpenLayers.Control.MouseToolbar.prototype = return btn; }, + stopAction: function(evt) { + Event.stop(evt); + }, + buttonClick: function(evt) { this.switchModeTo(evt.div.action); Event.stop(evt); @@ -69,11 +79,14 @@ OpenLayers.Control.MouseToolbar.prototype = */ defaultMouseDown: function (evt) { this.mouseDragStart = evt.xy.copyOf(); - if (evt.shiftKey) { + if (evt.shiftKey && this.mode !="zoombox") { this.switchModeTo("zoombox"); - } else if (evt.altKey) { + } else if (evt.altKey && this.mode !="measure") { this.switchModeTo("measure"); + } else if (!this.mode) { + this.switchModeTo("pan"); } + switch (this.mode) { case "zoombox": this.map.div.style.cursor = "crosshair"; @@ -99,7 +112,6 @@ OpenLayers.Control.MouseToolbar.prototype = }, switchModeTo: function(mode) { - console.log('leave mode?'+mode+","+this.mode); if (mode != this.mode) { this.mode = mode; this.buttons[mode].firstChild.src = this.buttons[mode].activeImgLocation;