For controls with multiple handlers, we now tack them on to a handlers object. The base destroy takes care of the handlers. r=crschmidt,uz/2 (closes #1338)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6106 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -76,24 +76,12 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
feature: null,
|
||||
|
||||
/**
|
||||
* Property: dragHandler
|
||||
* {<OpenLayers.Handler.Drag>}
|
||||
*/
|
||||
dragHandler: null,
|
||||
|
||||
/**
|
||||
* Property: dragCallbacks
|
||||
* {Object} The functions that are sent to the drag handler for callback.
|
||||
*/
|
||||
dragCallbacks: {},
|
||||
|
||||
/**
|
||||
* Property: featureHandler
|
||||
* {<OpenLayers.Handler.Feature>}
|
||||
*/
|
||||
featureHandler: null,
|
||||
|
||||
/**
|
||||
* Property: featureCallbacks
|
||||
* {Object} The functions that are sent to the feature handler for callback.
|
||||
@@ -119,20 +107,24 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
initialize: function(layer, options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.layer = layer;
|
||||
this.dragCallbacks = OpenLayers.Util.extend({down: this.downFeature,
|
||||
move: this.moveFeature,
|
||||
up: this.upFeature,
|
||||
out: this.cancel,
|
||||
done: this.doneDragging
|
||||
}, this.dragCallbacks);
|
||||
this.dragHandler = new OpenLayers.Handler.Drag(this, this.dragCallbacks);
|
||||
this.featureCallbacks = OpenLayers.Util.extend({over: this.overFeature,
|
||||
out: this.outFeature
|
||||
}, this.featureCallbacks);
|
||||
var handlerOptions = {geometryTypes: this.geometryTypes};
|
||||
this.featureHandler = new OpenLayers.Handler.Feature(this, this.layer,
|
||||
this.featureCallbacks,
|
||||
handlerOptions);
|
||||
this.handlers = {
|
||||
drag: new OpenLayers.Handler.Drag(
|
||||
this, OpenLayers.Util.extend({
|
||||
down: this.downFeature,
|
||||
move: this.moveFeature,
|
||||
up: this.upFeature,
|
||||
out: this.cancel,
|
||||
done: this.doneDragging
|
||||
}, this.dragCallbacks)
|
||||
),
|
||||
feature: new OpenLayers.Handler.Feature(
|
||||
this, this.layer, OpenLayers.Util.extend({
|
||||
over: this.overFeature,
|
||||
out: this.outFeature
|
||||
}, this.featureCallbacks),
|
||||
{geometryTypes: this.geometryTypes}
|
||||
)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -141,8 +133,6 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
destroy: function() {
|
||||
this.layer = null;
|
||||
this.dragHandler.destroy();
|
||||
this.featureHandler.destroy();
|
||||
OpenLayers.Control.prototype.destroy.apply(this, []);
|
||||
},
|
||||
|
||||
@@ -154,7 +144,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Boolean} Successfully activated the control and feature handler.
|
||||
*/
|
||||
activate: function() {
|
||||
return (this.featureHandler.activate() &&
|
||||
return (this.handlers.feature.activate() &&
|
||||
OpenLayers.Control.prototype.activate.apply(this, arguments));
|
||||
},
|
||||
|
||||
@@ -167,8 +157,8 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
deactivate: function() {
|
||||
// the return from the handlers is unimportant in this case
|
||||
this.dragHandler.deactivate();
|
||||
this.featureHandler.deactivate();
|
||||
this.handlers.drag.deactivate();
|
||||
this.handlers.feature.deactivate();
|
||||
this.feature = null;
|
||||
this.dragging = false;
|
||||
this.lastPixel = null;
|
||||
@@ -184,9 +174,9 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* feature - {<OpenLayers.Feature.Vector>} The selected feature.
|
||||
*/
|
||||
overFeature: function(feature) {
|
||||
if(!this.dragHandler.dragging) {
|
||||
if(!this.handlers.drag.dragging) {
|
||||
this.feature = feature;
|
||||
this.dragHandler.activate();
|
||||
this.handlers.drag.activate();
|
||||
this.over = true;
|
||||
// TBD replace with CSS classes
|
||||
this.map.div.style.cursor = "move";
|
||||
@@ -238,7 +228,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
upFeature: function(pixel) {
|
||||
if(!this.over) {
|
||||
this.dragHandler.deactivate();
|
||||
this.handlers.drag.deactivate();
|
||||
this.feature = null;
|
||||
// TBD replace with CSS classes
|
||||
this.map.div.style.cursor = "default";
|
||||
@@ -265,9 +255,9 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* feature - {<OpenLayers.Feature.Vector>} The feature that the mouse left.
|
||||
*/
|
||||
outFeature: function(feature) {
|
||||
if(!this.dragHandler.dragging) {
|
||||
if(!this.handlers.drag.dragging) {
|
||||
this.over = false;
|
||||
this.dragHandler.deactivate();
|
||||
this.handlers.drag.deactivate();
|
||||
// TBD replace with CSS classes
|
||||
this.map.div.style.cursor = "default";
|
||||
this.feature = null;
|
||||
@@ -283,7 +273,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Called when the drag handler detects a mouse-out (from the map viewport).
|
||||
*/
|
||||
cancel: function() {
|
||||
this.dragHandler.deactivate();
|
||||
this.handlers.drag.deactivate();
|
||||
this.over = false;
|
||||
},
|
||||
|
||||
@@ -295,8 +285,8 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* map - {<OpenLayers.Map>} The control's map.
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.dragHandler.setMap(map);
|
||||
this.featureHandler.setMap(map);
|
||||
this.handlers.drag.setMap(map);
|
||||
this.handlers.feature.setMap(map);
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user