Toggle using one button

  • Hello everyone,

    I've created a button with an action to open a google map but I want to use it in a toggle fashion to close it and haven't found an example to toggle.

    Any help would be appreciated

    Robert

  • Ok, actually got it working on based on a great example. Only thing now is what would I have to do to show two different bits of text. Would the average user understand "Toggle Map" as show/hide map?

  • Hi Robert,

    You could change the setting of onhover, like this:

    Code
    onclickA="action(showmap,maps); set(onclick, onclickB() ); set(onhover,showtext(Hide MAP,csmall));"
    onclickB="action(hidemap,maps); set(onclick, onclickA() ); set(onhover,showtext(Show MAP,csmall));"

    SAlut.

  • Hi Michel,

    Doesn't seem to work. The text doesn't appear at all and it only opens the map and doesn't close it.

    <plugin name="map_btn" visible="false" url="newcontrols.png" crop="172|34|29|25" keep="true"
    align="leftbottom" x="172" y="0" handcursor="true" alpha="0" zorder="1000"
    onclickA="action(showmap,maps); set (onclick, onclickB(); set(onhover,showtext(Show MAP,csmall));"
    onclickB="action(hidemap,maps); set(onclick, onclickA(); set(onhover,showtext(Hide MAP,csmall));"
    onclick="onclickA();"
    onhover="showtext(Show Map,csmall)"
    onover="tween(alpha,1,0.1)" onout="tween(alpha,0,0.5)" onloaded="delayedcall(1,set(visible,true));"/>

    Edited once, last by rbudnikas (September 24, 2010 at 8:16 PM).

  • Hi,

    This must work:
    onclickA="action(showmap,maps); set(onclick, onclickB() ); set(onhover,showtext(Hide MAP,buttonstyle));"

    Quote

    ..the map and doesn't close it.

    perhaps the missing </action> in your code:

    SAlut.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!