making ModifyFeature control in standalone mode trigger the beforefeaturemodified event. r=bartvde (closes #3009
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11146 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -351,18 +351,23 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: selectFeature
|
||||
* Called when the select feature control selects a feature.
|
||||
* APIMethod: selectFeature
|
||||
* Select a feature for modification in standalone mode. In non-standalone
|
||||
* mode, this method is called when the select feature control selects a
|
||||
* feature. Register a listener to the beforefeaturemodified event and
|
||||
* return false to prevent feature modification.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>} the selected feature.
|
||||
*/
|
||||
selectFeature: function(feature) {
|
||||
if (!this.standalone || this.beforeSelectFeature(feature) !== false) {
|
||||
this.feature = feature;
|
||||
this.modified = false;
|
||||
this.resetVertices();
|
||||
this.dragControl.activate();
|
||||
this.onModificationStart(this.feature);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -648,7 +648,7 @@
|
||||
|
||||
function test_standalone(t) {
|
||||
|
||||
t.plan(17);
|
||||
t.plan(18);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
|
||||
@@ -673,6 +673,7 @@
|
||||
var log = [];
|
||||
layer.events.on({
|
||||
beforefeaturemodified: function(evt) {
|
||||
layer.events.unregister("beforefeaturemodified", this, arguments.callee);
|
||||
log.push(evt);
|
||||
},
|
||||
featuremodified: function(evt) {
|
||||
@@ -690,7 +691,9 @@
|
||||
|
||||
// manually select feature for editing
|
||||
control.selectFeature(f1);
|
||||
t.eq(log.length, 1, "[select f1] beforefeaturemodified triggered");
|
||||
t.ok(control.feature === f1, "[select f1] control.feature set to f1");
|
||||
log = []
|
||||
|
||||
// manually unselect feature for editing
|
||||
control.unselectFeature(f1);
|
||||
|
||||
Reference in New Issue
Block a user