diff --git a/lib/OpenLayers/Control/SelectFeature.js b/lib/OpenLayers/Control/SelectFeature.js index feb3588b94..55d79cef56 100644 --- a/lib/OpenLayers/Control/SelectFeature.js +++ b/lib/OpenLayers/Control/SelectFeature.js @@ -484,6 +484,13 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, { if(cont !== false) { layer.selectedFeatures.push(feature); this.highlight(feature); + // if the feature handler isn't involved in the feature + // selection (because the box handler is used or the + // feature is selected programatically) we fake the + // feature handler to allow unselecting on click + if(!this.handlers.feature.lastFeature) { + this.handlers.feature.lastFeature = layer.selectedFeatures[0]; + } layer.events.triggerEvent("featureselected", {feature: feature}); this.onSelect.call(this.scope, feature); }