SelectFeature control - highlightOnly and toggle don't play well together, p=me, r=bartvde (closes #2812)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11633 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-03-07 07:57:14 +00:00
parent e8a3885d27
commit 1f58346772
2 changed files with 125 additions and 2 deletions

View File

@@ -463,8 +463,23 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
*/
unhighlight: function(feature) {
var layer = feature.layer;
feature._lastHighlighter = feature._prevHighlighter;
delete feature._prevHighlighter;
// three cases:
// 1. there's no other highlighter, in that case _prev is undefined,
// and we just need to undef _last
// 2. another control highlighted the feature after we did it, in
// that case _last references this other control, and we just
// need to undef _prev
// 3. another control highlighted the feature before we did it, in
// that case _prev references this other control, and we need to
// set _last to _prev and undef _prev
if(feature._prevHighlighter == undefined) {
delete feature._lastHighlighter;
} else if(feature._prevHighlighter == this.id) {
delete feature._prevHighlighter;
} else {
feature._lastHighlighter = feature._prevHighlighter;
delete feature._prevHighlighter;
}
layer.drawFeature(feature, feature.style || feature.layer.style ||
"default");
this.events.triggerEvent("featureunhighlighted", {feature : feature});