Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Update Buttons State — Gideros Forum

Update Buttons State

ThuwizThuwiz Member
edited May 2016 in General questions
Hello Everyone,

I have three buttons and I'm trying to implement an event which is only possible to select one at a time. It would be similar to a radio box.

I'm using the button class available in gitHub. The problem is that I don't know how instantiate the class button to update the state.

Many thanks.
English isn’t my first language, so please excuse any mistakes.

Comments

  • talistalis Guru
    Accepted Answer
    Simple solution;
    -Define a global variable like btn1selected. set it to false in the beginning.
    -On press of your any button set it to true.
    -In the beginning of every on press button check this variable(btn1selected) with an if. if true it means that user already selected on of the buttons. so simply deactivate other two and select yours.
  • talistalis Guru
    edited May 2016 Accepted Answer
    After a short search (like 20 seconds :D ) found another answer here see this post please.
    http://giderosmobile.com/forum/discussion/1456/button-onoff-state/p1
    So by using this code and the idea above it seems easy.
  • antixantix Member
    edited May 2016 Accepted Answer
    Here's a small solution. You make a group (table) to hold all your toggle buttons. On creating the ToggleButton you supply the group it belongs to. Now whenever you click a Togglebutton, all the others belonging to that group get unseleced.

    Here is an example project with a new class "Togglebutton" that does just that :)

    Just ask if you have questions ;)
    zip
    zip
    togglebuttons.zip
    86K

    Likes: Thuwiz

    +1 -1 (+1 / -0 )Share on Facebook
  • ThuwizThuwiz Member
    @talis - I tried this on/off method before but the switch class was removing the entire button from the scene and I tried your method too but I was having trouble with the global variable.

    @antix - That was perfect and works exactly as I wanted.

    Thanks everyone for the help.

    Likes: antix

    English isn’t my first language, so please excuse any mistakes.
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.