On Mon, Jul 27, 2009 at 12:02 PM, Florian Diederichs<florian_diederi...@hotmail.com> wrote: > > Hi all, > > I have encountered a problem with the SelectFeature-Control. I wonder if > anybody has a workaround/patch, knows anything, or is seeing something I am > not. Any help would be very much appreciated. > > The problems arises every time I use this function: > > select: new OpenLayers.Control.SelectFeature( > kunden, > { > onSelect: onFeatureSelect, > onUnselect: onFeatureUnselect, > clickout: true, toggle: true, > multiple: true, hover: false, > box: true, > toggleKey: "ctrlKey", > multipleKey: "shiftKey" > } > ) > > > It can also be found at http://openlayers.org/dev/examples/ - Open Layers > Select Feature Example. > > > When you first draw some points and then select the control allowing you to > select multiple features with a box, unselecting by clicking out isn't > working. (With "click out to unselect features" = true of course). Only when > you click on one of the features, the others get unselected. After that, > unselecting by clicking out works sort of. > > Because then, when you unselect by clicking out, only the feature that got > selected last is rendered as unselected, the others remain in their > graphical state of being selected. Although they aren't selected, at least > they are not in the selectedfeatures array of the layer. > > I wonder if anybody has a workaround/patch, knows anything, or if i'm just > doing something wrong. Help would be very much appreciated.
Hi. I know what's going on: when selecting features by drawing a box the feature handler does not participate in the selection so it never triggers the clickout callback. I don't see any other way than faking the feature handler, see the patch attached to this email. Cheers -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com http://www.camptocamp.com
Index: lib/OpenLayers/Control/SelectFeature.js =================================================================== --- lib/OpenLayers/Control/SelectFeature.js (revision 9573) +++ lib/OpenLayers/Control/SelectFeature.js (working copy) @@ -540,6 +540,11 @@ } } this.multiple = prevMultiple; + // fake the feature handler to allow unselecting + // features on clickout + if(layer.selectedFeatures.length > 0) { + this.handlers.feature.lastFeature = layer.selectedFeatures[0]; + } } },
_______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users