r3113@creusa: crschmidt | 2006-06-07 12:19:31 -0400
Changes to MouseToolbar: images are correct, fixes to various small mouse issues when combining clicked icons with modifier keys. git-svn-id: http://svn.openlayers.org/trunk/openlayers@552 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user