On Apr 20, 2010, at 12:05 , Casper Børgesen wrote:

> How do I set the scope for any of the callbacks associated in the 
> SelectFeature control?

It is recommended to use event listeners instead of callbacks, but if you want 
to use a callback, the way to set the scope is to use

OpenLayers.Function.bind(fn, scope);

Regards,
Andreas.

>  
> Var featSelect = new OpenLayers.Control.SelectFeature(
>               this.Layer,
>               {
>                   ...
>                   scope: this, // Appearently not for the callbacks
>                   callbacks: { 'click': this.handleClick }
>               }
> );
>  
> Using closures doesn’t seem to work either.
>  
> Var featSelect = new OpenLayers.Control.SelectFeature(
>               this.Layer,
>               {
>                   ...
>                   scope: this, // Appearently not for the callbacks
>                   callbacks: { 'click': function (feat) {
>                                             this.handleClick(feat);
>                                         }
>                   }
>               }
> );
>  
> I’m still working on learning how to understand the OpenLayers source and how 
> to handle scopes in general :)
> _______________________________________________
> Users mailing list
> [email protected]
> http://openlayers.org/mailman/listinfo/users

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to