Michael,<br><br>A OpenLayers.Control.Button only has one state: inactive. As soon as you click it (triggering the &#39;trigger&#39; function) it returns to it&#39;s inactive state.<br>If you want it to toggle, you should create a OpenLayers.Control override.<br>
<br>You could do that by creating an OpenLayers.Control and adding some events:<br><a href="http://dev.openlayers.org/releases/OpenLayers-2.11/examples/custom-control.html">http://dev.openlayers.org/releases/OpenLayers-2.11/examples/custom-control.html</a><br>
<br>Or by going into the code and create your own classes.<br><br>Hope this helps!<br><br><br>Regards,<br>Casper<br><br><div class="gmail_quote">On Tue, Oct 25, 2011 at 3:27 PM, Michael hedge <span dir="ltr">&lt;<a href="mailto:h3xagon@web.de">h3xagon@web.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello Developers,<br>
<br>
this might be an easy question but i dont found it on this forum so here i<br>
go:<br>
<br>
i created a button with a function:<br>
<br>
[CODE]<br>
new OpenLayers.Control.Button({<br>
              trigger: function() {<br>
                  if(this.box == null) {<br>
                        this.box = new OpenLayers.Handler.Box(control, {&quot;done&quot;:<br>
notice});<br>
                  }<br>
                  if(!activated) {<br>
                        activated = this.box.activate();<br>
                  } else {<br>
                        this.box.deactivate();<br>
                        activated = false;<br>
                  }<br>
              },<br>
                  displayClass: &quot;MyTest&quot;<br>
         })<br>
[/CODE]<br>
<br>
But on click on this button it wont change the icon.<br>
<br>
the initial load is with the inactive icon, which is correct, but on click<br>
it should change to active icon, defined the same way.<br>
<br>
This display class worked fine, when it changes a draw feature, for example:<br>
<br>
[CODE]<br>
new OpenLayers.Control.DrawFeature(layer,<br>
                OpenLayers.Handler.Path,<br>
                {&#39;displayClass&#39;: &#39;MyTest&#39;}),<br>
[/CODE]<br>
<br>
My Question is, why does it not work on buttons?<br>
<br>
And, if its just not supported by buttons, how can i call my own function<br>
out of a toolbar but with full optical support like the &quot;inactive-active&quot;<br>
thing?<br>
<br>
Sorry for my bad english.<br>
<br>
Regards<br>
<br>
Michael<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-Button-with-displayClass-tp6928809p6928809.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-Button-with-displayClass-tp6928809p6928809.html</a><br>

Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</font></blockquote></div><br>