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]