[OpenLayers-Users] OpenLayers.Control.Button with displayClass

Casper Span info at spatially-oriented.com
Tue Oct 25 09:59:57 EDT 2011


Michael,

A OpenLayers.Control.Button only has one state: inactive. As soon as you
click it (triggering the 'trigger' function) it returns to it's inactive
state.
If you want it to toggle, you should create a OpenLayers.Control override.

You could do that by creating an OpenLayers.Control and adding some events:
http://dev.openlayers.org/releases/OpenLayers-2.11/examples/custom-control.html

Or by going into the code and create your own classes.

Hope this helps!


Regards,
Casper

On Tue, Oct 25, 2011 at 3:27 PM, Michael hedge <h3xagon at web.de> wrote:

> Hello Developers,
>
> this might be an easy question but i dont found it on this forum so here i
> go:
>
> i created a button with a function:
>
> [CODE]
> new OpenLayers.Control.Button({
>              trigger: function() {
>                  if(this.box == null) {
>                        this.box = new OpenLayers.Handler.Box(control,
> {"done":
> notice});
>                  }
>                  if(!activated) {
>                        activated = this.box.activate();
>                  } else {
>                        this.box.deactivate();
>                        activated = false;
>                  }
>              },
>                  displayClass: "MyTest"
>         })
> [/CODE]
>
> But on click on this button it wont change the icon.
>
> the initial load is with the inactive icon, which is correct, but on click
> it should change to active icon, defined the same way.
>
> This display class worked fine, when it changes a draw feature, for
> example:
>
> [CODE]
> new OpenLayers.Control.DrawFeature(layer,
>                OpenLayers.Handler.Path,
>                {'displayClass': 'MyTest'}),
> [/CODE]
>
> My Question is, why does it not work on buttons?
>
> And, if its just not supported by buttons, how can i call my own function
> out of a toolbar but with full optical support like the "inactive-active"
> thing?
>
> Sorry for my bad english.
>
> Regards
>
> Michael
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-Button-with-displayClass-tp6928809p6928809.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111025/b8a91a72/attachment.html


More information about the Users mailing list