Ticket #1427: patch-1427-r7546-A1.diff
| File patch-1427-r7546-A1.diff, 3.2 kB (added by elemoine, 5 months ago) |
|---|
-
tests/Control/ModifyFeature.html
old new 164 164 } 165 165 166 166 function test_selectFeature(t) { 167 t.plan(1 5);167 t.plan(16); 168 168 var layer = new OpenLayers.Layer.Vector(); 169 169 var control = new OpenLayers.Control.ModifyFeature(layer); 170 170 control.vertices = []; 171 171 control.virtualVertices = []; 172 layer.events.on({"beforefeaturemodified": function(event) { 173 t.eq(event.feature, fakeFeature, "beforefeaturemodified triggered"); 174 }}); 172 var callback = function(obj) { 173 t.eq(obj.feature, fakeFeature, "beforefeaturemodified triggered"); 174 }; 175 layer.events.on({"beforefeaturemodified": callback}); 175 176 control.dragControl.activate = function() { t.ok(true, "drag Control activated"); } 176 177 control.onModificationStart = function(feature) { t.eq(feature.id, fakeFeature.id, "On Modification Start called with correct feature."); } 177 178 … … 211 212 212 213 // Features are removed whenever they exist 213 214 control.selectFeature({feature: fakeFeature}); 215 layer.events.un({"beforefeaturemodified": callback}); 216 217 // Check that selectFeature does nothing if a beforefeaturemodified 218 // listener returns false 219 var callback = function(obj) { 220 t.eq(obj.feature, fakeFeature, "beforefeaturemodified triggered"); 221 return false; 222 }; 223 layer.events.on({"beforefeaturemodified": callback}); 224 var getTestFunction = function(funcName) { 225 return function() { 226 t.fail(funcName + " called with a beforefeaturemodified listener returned false"); 227 }; 228 }; 229 control.resetVertices = getTestFunction("resetVertices"); 230 control.dragControl.activate = getTestFunction("dragControl.activate"); 231 control.onModificationStart = getTestFunction("onModificationStart"); 232 control.selectFeature({feature: fakeFeature}); 233 layer.events.un({"beforefeaturemodified": callback}); 214 234 215 235 control.destroy(); 216 236 layer.destroy(); -
lib/OpenLayers/Control/ModifyFeature.js
old new 297 297 * selected feature. 298 298 */ 299 299 selectFeature: function(object) { 300 this.feature = object.feature; 301 this.resetVertices(); 302 this.dragControl.activate(); 303 this.onModificationStart(this.feature); 304 this.layer.events.triggerEvent("beforefeaturemodified", 305 {feature: this.feature}); 300 var cont = this.layer.events.triggerEvent( 301 "beforefeaturemodified", {feature: object.feature} 302 ); 303 if(cont !== false) { 304 this.feature = object.feature; 305 this.resetVertices(); 306 this.dragControl.activate(); 307 this.onModificationStart(this.feature); 308 } 306 309 }, 307 310 308 311 /**
