SSK2: More than one set of radio buttons?

I’m sure it’s me, but how can I have more than one set of radio buttons?

Eg"

Option1:  [A]   [B]

Option2:  [X] [Y] [Z]

It all displays fine, except A is highlighted by default. If I click X, A deselects.   I’m looking for A/B for 1, XYZ for 2.

Using 2017.012 version.

-- Choose KM or Miles ssk.easyIFC:quickEmbossedLabel( group, "Metric/Imperial", 150, 100,"helvetica",24,{1,1,1} ) local distance = ssk.easyIFC:presetRadio( group, "default", 300, 100, 70, 40, "KM", onRelease , {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24}) distance2=ssk.easyIFC:presetRadio( group, "default", 400, 100, 70, 40, "Miles", onRelease, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) distance:toggle() -- Choose distance filter ssk.easyIFC:quickEmbossedLabel( group2, "Search Range", 150, 200,"helvetica",24,{1,1,1} ) local reach = ssk.easyIFC:presetRadio( group2, "default", 275, 200, 40, 40, "25", onRelease2 , {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24}) ssk.easyIFC:presetRadio( group2, "default", 325, 200, 40, 40, "50", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) ssk.easyIFC:presetRadio( group2, "default", 375, 200, 40, 40, "100", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) ssk.easyIFC:presetRadio( group2, "default", 425, 200, 40, 40, "250", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) reach:toggle()

Thoughts?

As your code seems to show that you understand,

SSK2 Radio buttons communicate via their parent group.  Thus, if you need two independent sets of radio buttons, put them in separate groups.

I see you are doing this in your code, or rather you seem to be doing this.

The only way this would fail, is if group and group2 are nil or somehow the same group.  If they are both nil, then SSK2 will automatically put the buttons in display.currentStage.

Please verify that the groups are not nil and not the same.

You can do this by putting these lines of code after your creation code above:

print( "-------------------------------" ) print( group, group2, group ~= group2 ) print( "-------------------------------" )

Meanwhile, I will verify this is working properly and post back in a bit.

You are correct, they WERE in the same group, I created a second one and voila.

14 minutes response time… impressive  :smiley:

Thank you Ed.

For reference to others… Here’s the corrected version.

group = display.newGroup( ). -- This correct group 1 -- Choose KM or Miles ssk.easyIFC:quickEmbossedLabel( group, "Metric/Imperial", 150, 100,"helvetica",24,{1,1,1} ) local distance = ssk.easyIFC:presetRadio( group, "default", 300, 100, 70, 40, "KM", onRelease , {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24}) ssk.easyIFC:presetRadio( group, "default", 400, 100, 70, 40, "Miles", onRelease, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) distance:toggle() group2=display.newGroup() -- \*This corrects group 2 -- Choose distance filter ssk.easyIFC:quickEmbossedLabel( group2, "Search Range", 150, 200,"helvetica",24,{1,1,1} ) local reach = ssk.easyIFC:presetRadio( group2, "default2", 275, 200, 40, 40, "25", onRelease2 , {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24}) ssk.easyIFC:presetRadio( group2, "default2", 325, 200, 40, 40, "50", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) ssk.easyIFC:presetRadio( group2, "default2", 375, 200, 40, 40, "100", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) ssk.easyIFC:presetRadio( group2, "default2", 425, 200, 40, 40, "250", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) reach:toggle()

FYI, I updated the validation test suite to better test this:

https://github.com/roaminggamer/SSK2/raw/master/validation.zip

https://www.youtube.com/watch?v=XK__RZpUu5c&feature=youtu.be

A quick followup. 

Is there a way to set a radio button on?

I assume I can run Toggle 3 times and keep checking the text, but I have to think there is a better way.

I see there is a ‘isPressed’ = true, but you specifically caution it to be read only.

Specifically I’m using the 3 radio buttons in a setup screen, and I want to pre-set them to the values loaded in setup. So when I come into the screen I want button 2 (for example) to be highlighted.

Checked: This link on your docs.

Checked: Validation program in case it was preset.

You can call toggle() to force toggle a radio button (or any other button):

>> buttonInstance:toggle( [noDispatch] ) - Toggle the button and execute its listener.

  • Tip:  If you do not want to execute the button’s listener, pass true to the method.

    – pseudocode follows… local buttons = {} local tmp = easyIFC:presetRadio( … buttons[1] = tmp local tmp = easyIFC:presetRadio( … buttons[2] = tmp local tmp = easyIFC:presetRadio( … buttons[3] = tmp – toggle button 2 buttons[2]:toggle( true ) – do not execute button callback/listener

As your code seems to show that you understand,

SSK2 Radio buttons communicate via their parent group.  Thus, if you need two independent sets of radio buttons, put them in separate groups.

I see you are doing this in your code, or rather you seem to be doing this.

The only way this would fail, is if group and group2 are nil or somehow the same group.  If they are both nil, then SSK2 will automatically put the buttons in display.currentStage.

Please verify that the groups are not nil and not the same.

You can do this by putting these lines of code after your creation code above:

print( "-------------------------------" ) print( group, group2, group ~= group2 ) print( "-------------------------------" )

Meanwhile, I will verify this is working properly and post back in a bit.

You are correct, they WERE in the same group, I created a second one and voila.

14 minutes response time… impressive  :smiley:

Thank you Ed.

For reference to others… Here’s the corrected version.

group = display.newGroup( ). -- This correct group 1 -- Choose KM or Miles ssk.easyIFC:quickEmbossedLabel( group, "Metric/Imperial", 150, 100,"helvetica",24,{1,1,1} ) local distance = ssk.easyIFC:presetRadio( group, "default", 300, 100, 70, 40, "KM", onRelease , {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24}) ssk.easyIFC:presetRadio( group, "default", 400, 100, 70, 40, "Miles", onRelease, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) distance:toggle() group2=display.newGroup() -- \*This corrects group 2 -- Choose distance filter ssk.easyIFC:quickEmbossedLabel( group2, "Search Range", 150, 200,"helvetica",24,{1,1,1} ) local reach = ssk.easyIFC:presetRadio( group2, "default2", 275, 200, 40, 40, "25", onRelease2 , {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24}) ssk.easyIFC:presetRadio( group2, "default2", 325, 200, 40, 40, "50", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) ssk.easyIFC:presetRadio( group2, "default2", 375, 200, 40, 40, "100", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) ssk.easyIFC:presetRadio( group2, "default2", 425, 200, 40, 40, "250", onRelease2, {selRectFillColor = \_G\_,selLabelColor = \_R\_ ,labelSize = 24} ) reach:toggle()

FYI, I updated the validation test suite to better test this:

https://github.com/roaminggamer/SSK2/raw/master/validation.zip

https://www.youtube.com/watch?v=XK__RZpUu5c&feature=youtu.be

A quick followup. 

Is there a way to set a radio button on?

I assume I can run Toggle 3 times and keep checking the text, but I have to think there is a better way.

I see there is a ‘isPressed’ = true, but you specifically caution it to be read only.

Specifically I’m using the 3 radio buttons in a setup screen, and I want to pre-set them to the values loaded in setup. So when I come into the screen I want button 2 (for example) to be highlighted.

Checked: This link on your docs.

Checked: Validation program in case it was preset.

You can call toggle() to force toggle a radio button (or any other button):

>> buttonInstance:toggle( [noDispatch] ) - Toggle the button and execute its listener.

  • Tip:  If you do not want to execute the button’s listener, pass true to the method.

    – pseudocode follows… local buttons = {} local tmp = easyIFC:presetRadio( … buttons[1] = tmp local tmp = easyIFC:presetRadio( … buttons[2] = tmp local tmp = easyIFC:presetRadio( … buttons[3] = tmp – toggle button 2 buttons[2]:toggle( true ) – do not execute button callback/listener