How To Set Checkbox To Checked For Widgets 2.0?

Hi,

 

I added a checkbox and then some code after to set the checkbox.isOn to true. It prints that status but the checkbox is not actually checked. How would I get it to show checked by code? I am loading a data file and based on some data I need to have it checked.

 

Thanks!

 

local lblSaveEmail = display.newText("Remember Email Address", 50, 335, native.systemFont, 16) lblSaveEmail:setTextColor(255, 255, 255) group:insert( lblSaveEmail ) local chkSavePWord = widget.newSwitch { left = 10, top = 370, style = "checkbox", id = "Checkbox button2", initialSwitchState = false, onPress = chkSavePWordListener, } group:insert( chkSaveEmail ) local lblSavePWord = display.newText("Remember Password", 50, 375, native.systemFont, 16) lblSavePWord:setTextColor(255, 255, 255) group:insert( lblSavePWord ) local btnLogin = widget.newButton { left = 50, top = 420, label = "Login", id = "button\_1", onEvent = onbtnLoginButtonEvent, } group:insert( btnLogin ) chkSaveEmail.isOn = true print(chkSaveEmail.isOn)

 

Also, I know I can set it to true or false when I add the switch with the initialSwitchState but can i do it by code at another time?

After reading more I do not think it is possible. One solution that may work is what Naomi said in another reply is to remove the button and add it again switched on. It would be nice if they added a way to show it on/off by code.

This is supposed to be added in the next widget update. I too am anxiously waiting for a better fix.

Also, I know I can set it to true or false when I add the switch with the initialSwitchState but can i do it by code at another time?

After reading more I do not think it is possible. One solution that may work is what Naomi said in another reply is to remove the button and add it again switched on. It would be nice if they added a way to show it on/off by code.

This is supposed to be added in the next widget update. I too am anxiously waiting for a better fix.