[OpenLayers-Dev] stop propagation in handlers
Pierre GIRAUD
bluecarto at gmail.com
Mon Feb 25 09:07:22 EST 2008
Hello,
In most handlers, in fact those dealing with browser events, we need,
in most case need to stop event propagation, to prevent weird
behaviors. However, I think that propagation stop isn't complete.
Returning false to an event callback doesn't to be enough.
In my code, I play with vector symbols using SVG 'symbol' and 'use'
tags. The latter have a 'href' property with a reference to the
symbol. Ctrl+Click on the corresponding feature on the map opens a new
tab in FF.
I need this Ctrl+Click because I need to select several feature.
http://dev.openlayers.org/sandbox/camptocamp/vectorSymbols/examples/select-feature.html
I'm not really convinced by this solution but I would prefer something
like following. It seems to work fine for me in my example.
mousedown: function(evt) {
this.down = evt.xy;
- return this.handle(evt) ? !this.stopDown : true;
+ if (this.handle(evt)) {
+ if (this.stopDown) {
+ OpenLayers.Event.stop(evt, true);
+ }
+ return !this.stopDown;
+ } else {
+ return true;
+ }
},
Any comment on that ?
Regards,
Pierre
More information about the Dev
mailing list