Toggle Button Problem

Hey Folks,
I’m mostly enjoying my experience with Widget Candy. I am having a problem with the toggle buttons though. Here is the situation:

I created several toggle buttons. When I click one multiple times, it works
exactly as expected. However, if I toggle one, then toggle another
then go back and toggle the first one, the first one does not seem to
toggle properly. I’ve experimented with this a bit and it’s very
repeatable. It will be an issue for my app because I am expecting
people to toggle multiple buttons and it’s possible they might need to
untoggle one.

I am not using a toggle group. I truly want more than one button to
be able to be toggled.

Here’s the code that I’m using:

 local buttons =  
{Tardy="-",Bathroom="-",OffTask="-",Genius="+",Presented="+",RoomClean="+"}  
  
 local location = {"15%","25%","35%","45%","55%","65%"}  
 local myIcon = 44  
 local i = 1  
  
 for k,v in pairs(buttons) do  
 \_G.GUI.NewButton(  
 {  
 x = "center",  
 y = location[i],  
 width = "80%",  
 scale = \_G.GUIScale\*1.5,  
 name = k,  
 parentGroup = nil,  
  
 caption = k,  
 textAlign = "left",  
 icon = 44,  
 toggleButton = true,  
 toggleState = false,  
 onPress = function(EventData)  
EventData.Widget:set("caption", "Pressed!") end,  
 onRelease = function(EventData)  
 if buttons[k] == "+" then  
 myIcon = 7  
 else  
 myIcon = 8  
 end  
 if EventData.Props.toggleState == true then  
 EventData.Widget:set( { caption = k, icon = myIcon } )  
 else  
 EventData.Widget:set( { caption = k, icon = 44 } )  
 end  
 end,  
 } )  
 i = i + 1  
 end  

It seems like when one button is toggled, the other one things it is also. Any help you could provide would be greatly appreciated.
Best,
Michael [import]uid: 104085 topic_id: 28694 reply_id: 328694[/import]

Ok, I figured out a workaround to my problem. But I think there may still be a bug in Widget Candy. In the sample app that comes with Widget Candy, the toggle button does not have a toggleGroup name (and there is only one toggle button displayed in the non-group example).

When you try to use two toggle buttons (like the one in the sample code), this is what happens:

  • If you press one button, it looks pressed. If you press a second button, the first button looks “released” and the one you pressed looks pressed. In other words, the buttons are functioning like a group even though no group was specified.

So, I looked at the reference info and noticed that you could add a parameter called toggleGroup. And the reference went on to say that toggle buttons would function as a group if all has the same toggleGroup name. So, I gave all of my toggle buttons toggleGroup names, but I gave them all different toggleGroup names. Voila! Problem solved. For me, for now, anyway.

Just thought I would share. Also, it would be nice to get a reply from x-pressive.com at some point. [import]uid: 104085 topic_id: 28694 reply_id: 115743[/import]

Thanks for pointing that out, Michael. As you descriped correctly, this occurs if you did not specify any toggleGroup to your buttons. In the current version, Widget Candy looks for buttons with the same toggle group once you press a toggle button. If NO toggle group was assigned for the active button, Widget Candy treats all other toggle buttons where the toggle group value is also missing as identical (because both toggle groups are “nil” then -therefore identical). This is already fixed with the new version (update will be out within the next days).
[import]uid: 10504 topic_id: 28694 reply_id: 116470[/import]