[OpenLayers-Dev] stop propagation in handlers
Pierre GIRAUD
bluecarto at gmail.com
Wed Feb 27 04:45:57 EST 2008
On Tue, Feb 26, 2008 at 7:00 PM, Tim Schaub <tschaub at openplans.org> wrote:
> Hey-
>
>
> Pierre GIRAUD wrote:
> > 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.
>
> Yeah, three kinds of stopping really. The stopDown property is about
> stopping other listeners for the same events instance (same dom element
> in the case of browser events) from getting notified.
Understood.
>
> Do we want a separate property for stopping events from bubbling to
> other dom elements?
I don't really know.
>
> How about stopping the browser default for an event?
The following example includes shows three different feature using the
same symbol. If you try ctrl+click on each, the third one is the only
one that doesn't open a new tab.
http://dev.openlayers.org/sandbox/camptocamp/vectorSymbols/examples/svg/symbol_catalog3.svg
It seems like preventing browser defaut has no effect in that particular case.
By stopping the browser default, did you mean calling preventDefault ?
>
> I think lumping all three of those in one property (on a handler) might
> come back to haunt us.
Agreed.
Any suggestion ?
Pierre
>
> Tim
>
>
>
> > 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
> > _______________________________________________
> > Dev mailing list
> > Dev at openlayers.org
> > http://openlayers.org/mailman/listinfo/dev
> >
> > !DSPAM:4033,47c2cba2327006491211187!
> >
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
More information about the Dev
mailing list