ModifyFeature makes SelectFeature control behave/become like ModifyFeature, patch=bjornharrtell,tschaub, r=tschaub,me (closes #1741)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8302 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2008-11-07 08:46:02 +00:00
parent d82f73e9e7
commit 7c0fadd14a
3 changed files with 51 additions and 45 deletions

View File

@@ -65,19 +65,33 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
*/
box: false,
/**
* Property: onBeforeSelect
* {Function} Optional function to be called before a feature is selected.
* The function should expect to be called with a feature.
*/
onBeforeSelect: function() {},
/**
* APIProperty: onSelect
* {Function} Optional function to be called when a feature is selected.
* The function should expect to be called with a feature.
* The function should expect to be called with a feature.
*/
onSelect: function() {},
/**
* APIProperty: onUnselect
* {Function} Optional function to be called when a feature is unselected.
* The function should expect to be called with a feature.
* The function should expect to be called with a feature.
*/
onUnselect: function() {},
/**
* Property: scope
* {Object} The scope to use with the onBeforeSelect, onSelect, onUnselect
* callbacks. If null the scope will be this control.
*/
scope: this,
/**
* APIProperty: geometryTypes
@@ -312,17 +326,20 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
* feature - {<OpenLayers.Feature.Vector>}
*/
select: function(feature) {
var cont = this.layer.events.triggerEvent("beforefeatureselected", {
feature: feature
});
var cont = this.onBeforeSelect.call(this.scope, feature);
if(cont !== false) {
this.layer.selectedFeatures.push(feature);
var selectStyle = this.selectStyle || this.renderIntent;
this.layer.drawFeature(feature, selectStyle);
this.layer.events.triggerEvent("featureselected", {feature: feature});
this.onSelect(feature);
cont = this.layer.events.triggerEvent("beforefeatureselected", {
feature: feature
});
if(cont !== false) {
this.layer.selectedFeatures.push(feature);
var selectStyle = this.selectStyle || this.renderIntent;
this.layer.drawFeature(feature, selectStyle);
this.layer.events.triggerEvent("featureselected", {feature: feature});
this.onSelect.call(this.scope, feature);
}
}
},
@@ -339,7 +356,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
this.layer.drawFeature(feature, "default");
OpenLayers.Util.removeItem(this.layer.selectedFeatures, feature);
this.layer.events.triggerEvent("featureunselected", {feature: feature});
this.onUnselect(feature);
this.onUnselect.call(this.scope, feature);
},
/**