RadioButton group or programatically setting its isOn state

The documentation on the new switches seems a bit …

So trying to use the radio button switch and i am not figuring out how to do a radio-button group via the api.

So i want trying to do it manually but i see no way to set the state of a button.

I tried myRadioButton.isOn = false and it does not seem to change the display state of the button from on to off.

Is there an undocumented method on the switch?

[import]uid: 118012 topic_id: 33037 reply_id: 333037[/import]

Is there still currently no way to programmatically set a radio button ON/OFF? [import]uid: 58885 topic_id: 33037 reply_id: 139218[/import]

I don’t think so. Radio buttons are essentially useless in Corona right now… [import]uid: 132483 topic_id: 33037 reply_id: 139223[/import]

Is there still currently no way to programmatically set a radio button ON/OFF? [import]uid: 58885 topic_id: 33037 reply_id: 139218[/import]

I don’t think so. Radio buttons are essentially useless in Corona right now… [import]uid: 132483 topic_id: 33037 reply_id: 139223[/import]

it’s the basic thing in radio buttons. I also get stuck in my development to make change on one button effect the whole group buttons.

myRadioButton.isOn = false
It is not working programmatically,
I request corona staff to implement it. [import]uid: 108129 topic_id: 33037 reply_id: 140038[/import]

Hi all,
This feature is part of Widgets “2.0”, coming very soon. You’ll be able to set groups for radio buttons so they turn on/off automatically. I agree, this feature should have been implemented long ago, but it won’t be long before it is. We appreciate your patience. :slight_smile:

Brent [import]uid: 200026 topic_id: 33037 reply_id: 140056[/import]

One more issue with widgets. To use radio buttons/switches, i’ve to use the command widget.setTheme(“theme_ios”)
This command distrubs the scale of widget.newButtons every where in the project.
Please solve this as early as you can as i get stuck on these ignoreable issues while implementing radio buttons. If there is any solution, kindly update me. [import]uid: 108129 topic_id: 33037 reply_id: 140058[/import]

@Brent thanks! I hope the wait isn’t too long, I’ve been waiting for Widgets 2.0 for a while. [import]uid: 58885 topic_id: 33037 reply_id: 140070[/import]

Ok, I’ve resolved both of the issues. For Radio buttons on/off programatically. I am not making it ON/OFF, i am again initiallizing the buttons (removed the last ones) on any event occurs on radio buttons and setting its initial state (ON/OFF by default, it’s off). It’s code is given below.
and for scaling issue, i just comment the themeTable.button array and every thing other is fine.
– three buttons
local checkboxButton1
local checkboxButton2
local checkboxButton3

– Initialize their event functions at start
local onSwitchPress1
local onSwitchPress2
local onSwitchPress3

local text_default_color = {250,250,250}
local text_over_color = {221,221,221}

– Event functions of every radio button
function onSwitchPress1(event)
local switch = event.target
if (switch.isOn == true) then
display.remove(checkboxButton2)
display.remove(checkboxButton3)

checkboxButton2 = widget.newSwitch
{
left = 200,
top = 400,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress2,
}

checkboxButton3 = widget.newSwitch
{
left = 200,
top = 530,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress3,
}
end
end
function onSwitchPress2(event)
local switch = event.target
if (switch.isOn == true) then
display.remove(checkboxButton1)
display.remove(checkboxButton3)

checkboxButton1 = widget.newSwitch
{
left = 200,
top = 270,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress1,
}

checkboxButton3 = widget.newSwitch
{
left = 200,
top = 530,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress3,
}

end
end
function onSwitchPress3(event)
local switch = event.target
if (switch.isOn == true) then
display.remove(checkboxButton2)
display.remove(checkboxButton1)
checkboxButton2 = widget.newSwitch
{
left = 200,
top = 400,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress2,
}

checkboxButton1 = widget.newSwitch
{
left = 200,
top = 270,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress1,
}

end
end
checkboxButton1 = widget.newSwitch
{
left = 200,
top = 270,
style = “radio”,
id = “Checkbox button1”,
onPress = onSwitchPress1,
}

checkboxButton2 = widget.newSwitch
{
left = 200,
top = 400,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress2,
}

checkboxButton3 = widget.newSwitch
{
left = 200,
top = 530,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress3,
}

[import]uid: 108129 topic_id: 33037 reply_id: 140194[/import]

it’s the basic thing in radio buttons. I also get stuck in my development to make change on one button effect the whole group buttons.

myRadioButton.isOn = false
It is not working programmatically,
I request corona staff to implement it. [import]uid: 108129 topic_id: 33037 reply_id: 140038[/import]

Hi all,
This feature is part of Widgets “2.0”, coming very soon. You’ll be able to set groups for radio buttons so they turn on/off automatically. I agree, this feature should have been implemented long ago, but it won’t be long before it is. We appreciate your patience. :slight_smile:

Brent [import]uid: 200026 topic_id: 33037 reply_id: 140056[/import]

One more issue with widgets. To use radio buttons/switches, i’ve to use the command widget.setTheme(“theme_ios”)
This command distrubs the scale of widget.newButtons every where in the project.
Please solve this as early as you can as i get stuck on these ignoreable issues while implementing radio buttons. If there is any solution, kindly update me. [import]uid: 108129 topic_id: 33037 reply_id: 140058[/import]

@Brent thanks! I hope the wait isn’t too long, I’ve been waiting for Widgets 2.0 for a while. [import]uid: 58885 topic_id: 33037 reply_id: 140070[/import]

Ok, I’ve resolved both of the issues. For Radio buttons on/off programatically. I am not making it ON/OFF, i am again initiallizing the buttons (removed the last ones) on any event occurs on radio buttons and setting its initial state (ON/OFF by default, it’s off). It’s code is given below.
and for scaling issue, i just comment the themeTable.button array and every thing other is fine.
– three buttons
local checkboxButton1
local checkboxButton2
local checkboxButton3

– Initialize their event functions at start
local onSwitchPress1
local onSwitchPress2
local onSwitchPress3

local text_default_color = {250,250,250}
local text_over_color = {221,221,221}

– Event functions of every radio button
function onSwitchPress1(event)
local switch = event.target
if (switch.isOn == true) then
display.remove(checkboxButton2)
display.remove(checkboxButton3)

checkboxButton2 = widget.newSwitch
{
left = 200,
top = 400,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress2,
}

checkboxButton3 = widget.newSwitch
{
left = 200,
top = 530,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress3,
}
end
end
function onSwitchPress2(event)
local switch = event.target
if (switch.isOn == true) then
display.remove(checkboxButton1)
display.remove(checkboxButton3)

checkboxButton1 = widget.newSwitch
{
left = 200,
top = 270,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress1,
}

checkboxButton3 = widget.newSwitch
{
left = 200,
top = 530,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress3,
}

end
end
function onSwitchPress3(event)
local switch = event.target
if (switch.isOn == true) then
display.remove(checkboxButton2)
display.remove(checkboxButton1)
checkboxButton2 = widget.newSwitch
{
left = 200,
top = 400,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress2,
}

checkboxButton1 = widget.newSwitch
{
left = 200,
top = 270,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress1,
}

end
end
checkboxButton1 = widget.newSwitch
{
left = 200,
top = 270,
style = “radio”,
id = “Checkbox button1”,
onPress = onSwitchPress1,
}

checkboxButton2 = widget.newSwitch
{
left = 200,
top = 400,
style = “radio”,
id = “Checkbox button2”,
onPress = onSwitchPress2,
}

checkboxButton3 = widget.newSwitch
{
left = 200,
top = 530,
style = “radio”,
id = “Checkbox button3”,
onPress = onSwitchPress3,
}

[import]uid: 108129 topic_id: 33037 reply_id: 140194[/import]

@haroon:

"
One more issue with widgets. To use radio buttons/switches, i’ve to use the command widget.setTheme(“theme_ios”)
This command distrubs the scale of widget.newButtons every where in the project.
Please solve this as early as you can as i get stuck on these ignoreable issues while implementing radio buttons. If there is any solution, kindly update me."

I have tested this against the new widget.newButton code (part of the widget library re-write) and I cannot reproduce this.

Just wanted to let you know :wink: [import]uid: 84637 topic_id: 33037 reply_id: 141073[/import]

@haroon:

"
One more issue with widgets. To use radio buttons/switches, i’ve to use the command widget.setTheme(“theme_ios”)
This command distrubs the scale of widget.newButtons every where in the project.
Please solve this as early as you can as i get stuck on these ignoreable issues while implementing radio buttons. If there is any solution, kindly update me."

I have tested this against the new widget.newButton code (part of the widget library re-write) and I cannot reproduce this.

Just wanted to let you know :wink: [import]uid: 84637 topic_id: 33037 reply_id: 141073[/import]

I spent several hours on a plane (no wifi) trying to figure out that there was no programatic way to change a radio button. Not to complain but it should be a bit concerning that aren’t useful. Haroon, you are a genius to think of something so simple as replace the button. For that matter you can simplify it even further and just put an image on the screen that the handler then replaces the image upon touch which is easy to do programmatically. 2 cents now that I know how to work around this. [import]uid: 144922 topic_id: 33037 reply_id: 142171[/import]

I spent 3.5 hrs trying to make radio buttons work the other day…
I think they should put some information in the api doc about it not being fully functional yet.

Sucks to waste that much time on it, but your work around Haroon is a reasonable enough solution. [import]uid: 170004 topic_id: 33037 reply_id: 142186[/import]

I spent several hours on a plane (no wifi) trying to figure out that there was no programatic way to change a radio button. Not to complain but it should be a bit concerning that aren’t useful. Haroon, you are a genius to think of something so simple as replace the button. For that matter you can simplify it even further and just put an image on the screen that the handler then replaces the image upon touch which is easy to do programmatically. 2 cents now that I know how to work around this. [import]uid: 144922 topic_id: 33037 reply_id: 142171[/import]