[OpenLayers-Users] Multiple click control stopClick precedence/order

Eric Lemoine eric.lemoine at camptocamp.com
Mon May 10 02:24:31 EDT 2010


On Wednesday, May 5, 2010, Matthew Williamson <matthewdw at gmail.com> wrote:
> Hello list,
> I'm trying to set up a vector layer to respond to click events, and also have a map-level click handler that gets fired if the click was not on one of my features. I'm doing this with two controls, one with a OpenLayers.Handler.Feature and one with a OpenLayers.Handler.Click.
>
> This is what puzzles me:
> In my first attempt: The feature click control is added first, and its stopSingle value is true. The map click control is added last, and its stopSingle value is false. When I click on a feature, the handler for the feature click control fires first (this makes sense), and then the map click control fires (this didn't make sense to me).

The handler that is activated last should be triggered first.

>
> Then, I tried setting stopSingle = true on the map click control as well. This stopped the feature click control from firing at all!

This makes sense to me.

> So, I conclude that--even though the map click control was added last, AND executes last, the stopSingle value on the map click handler is evaluated first?? Why is this? How can I ensure that the feature click handler control is able to stop the propagation to the map click handler, preferably regardless of the order in which they are added to the map?

AFAICT you need to activate the feature handler last. You also need to
set stopClick to true in this handler. And you may also need to set
stopDown and stopUp to true in this handler.


>
> To eliminate some confusion: yes, I know about the SelectFeature control. So far as I can tell, I can't use that--my features are points with large, mostly transparent icons that tend to overlap and cover the whole map (in which case SelectFeature intercepts mousedowns on the whole icon and makes drag-panning impossible), therefore I only want to respond to clicks near the center (canceling propagation in that case). If someone can tell me how to make that work with SelectFeature, I'd be glad to use that instead.

You could possibly use two point features, with one dedicated to
feature selection.


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.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list