modify the drag handler so that it only modifies IE's document.onselectstart while dragging - add jsodc text - all browser event handlers now return a boolean - activate and deactivate respect the return of the parent class and return the same
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2908 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -16,16 +16,22 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
|
||||
* When a mousedown event is received, we want to record it, but not set
|
||||
* 'dragging' until the mouse moves after starting.
|
||||
*
|
||||
* @type boolean
|
||||
* @type Boolean
|
||||
**/
|
||||
started: false,
|
||||
|
||||
/** @type boolean **/
|
||||
dragging: null,
|
||||
/** @type Boolean **/
|
||||
dragging: false,
|
||||
|
||||
/** @type OpenLayers.Pixel **/
|
||||
start: null,
|
||||
|
||||
/**
|
||||
* @type Function
|
||||
* @private
|
||||
*/
|
||||
oldOnselectstart: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -40,10 +46,16 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
|
||||
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mousedown events
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* @return Should the event propagate
|
||||
*/
|
||||
mousedown: function (evt) {
|
||||
if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
|
||||
this.started = true;
|
||||
this.dragging = null;
|
||||
this.dragging = false;
|
||||
this.start = evt.xy.clone();
|
||||
// TBD replace with CSS classes
|
||||
this.map.div.style.cursor = "move";
|
||||
@@ -51,58 +63,113 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
|
||||
OpenLayers.Event.stop(evt);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mousemove events
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* @return Should the event propagate
|
||||
*/
|
||||
mousemove: function (evt) {
|
||||
if (this.started) {
|
||||
this.dragging = true;
|
||||
this.callback("move", [evt.xy]);
|
||||
if(document.onselectstart) {
|
||||
if(!this.oldOnselectstart) {
|
||||
this.oldOnselectstart = document.onselectstart;
|
||||
document.onselectstart = function() {return false;}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mouseup events
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* @return Should the event propagate
|
||||
*/
|
||||
mouseup: function (evt) {
|
||||
if (this.started) {
|
||||
this.started = false;
|
||||
this.started = false;
|
||||
this.dragging = false;
|
||||
// TBD replace with CSS classes
|
||||
this.map.div.style.cursor = "default";
|
||||
this.callback("up", [evt.xy]);
|
||||
if(document.onselectstart) {
|
||||
document.onselectstart = this.oldOnselectstart;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mouseout events
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* @return Should the event propagate
|
||||
*/
|
||||
mouseout: function (evt) {
|
||||
if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
||||
this.started = false;
|
||||
this.dragging = null;
|
||||
this.dragging = false;
|
||||
// TBD replace with CSS classes
|
||||
this.map.div.style.cursor = "default";
|
||||
this.callback("out", []);
|
||||
if(document.onselectstart) {
|
||||
document.onselectstart = this.oldOnselectstart;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* The drag handler captures the click event. If something else registers
|
||||
* for clicks on the same element, its listener will not be called after a
|
||||
* drag.
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* @return Should the event propagate
|
||||
*/
|
||||
click: function (evt) {
|
||||
// throw away the first left click event that happens after a mouse up
|
||||
if (OpenLayers.Event.isLeftClick(evt) && this.dragging) {
|
||||
this.dragging = true;
|
||||
return false;
|
||||
}
|
||||
this.started = false;
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Activate the handler.
|
||||
* @type Boolean
|
||||
* @return Was activation successful. Returns false if already active.
|
||||
*/
|
||||
activate: function() {
|
||||
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
|
||||
this.dragging = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*
|
||||
* Deactivate the handler.
|
||||
* @type Boolean
|
||||
* @return Was deactivation successful. Returns false if not already active.
|
||||
*/
|
||||
click: function (evt) {
|
||||
// throw away the first left click event that happens after a mouse up
|
||||
if (OpenLayers.Event.isLeftClick(evt) && this.dragging != null) {
|
||||
this.dragging = null;
|
||||
return false;
|
||||
deactivate: function() {
|
||||
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
|
||||
this.dragging = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
this.started = false;
|
||||
},
|
||||
|
||||
activate: function (evt) {
|
||||
OpenLayers.Handler.prototype.activate.apply(this, arguments);
|
||||
document.onselectstart = function() { return false; };
|
||||
this.dragging = null;
|
||||
},
|
||||
|
||||
deactivate: function (evt) {
|
||||
OpenLayers.Handler.prototype.deactivate.apply(this, arguments);
|
||||
document.onselectstart = null;
|
||||
this.dragging = null;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
Reference in New Issue
Block a user