SSK2: Toggle buttons ignore the "toggled*" parameters

I’m trying to make some toggle buttons that change their appearance when toggled (clicked once) and then revert to their original visual state when clicked a second time.

Here’s the code I’m trying:

local tagGroup = display.newGroup() local buttonPresetParams = {    labelSize          = 12,    labelFont          = gameFont,    labelOffset        = { 0, 0 },    lockedRectFillColor = { 0.9, 0.9, 0.9, 1 },    labelColor         = { 0, 0, 0, 0.95 },    unselRectFillColor = { 1, 1, 1, 1 },    selRectFillColor   = { 0.1, 0.1, 0.1, 1 },    selLabelColor = { 1, 1, 1, 1 },    toggledRectFillColor = { 0.5, 0.1, 0.1, 1 },    toggledStrokeColor = { 0.6, 0.8, 0.1, 1 },    strokeWidth        = 5,    strokeColor        = { 0, 0, 0, 0.5 },    cornerRadius = 2,    emboss             = false, } ssk.easyIFC:addButtonPreset( "toggle\_1", buttonPresetParams ) local function onToggle( event )    print("Pressed Button: " .. tostring( event.target:getText() ) )    print("Is pressed ?= " .. tostring( event.target:pressed() ) ) end local toggleButton1 = ssk.easyIFC:presetToggle( tagGroup, "toggle\_1", 100, 100, 120, 30, "Hello", onToggle )

The toggle event gets fired but the toggledRectFillColor and toggledStrokeColor are never applied. What actually happens is, when I click/toggle the button, it applies the selRectFillColor and selLabelColor , but a second click only reverts to the labelColor. The fill color remains the same as  selRectFillColor.

I expected the button would get the toggled* settings when clicked. Or, at least get back the original  unselRectFillColor when I click it a second time (untoggle).

No errors in the console, just the event handler prints. Corona version is 3068. Testing in both the simulator (Mac) and on a device (iPad).

Thanks in advance! 

What version of SSK2 are you running?

https://roaminggamer.github.io/RGDocs/pages/SSK2/#are-you-using-the-latest-version

Sorry, forgot to add it:

version is  2017.010

I’m running 2017.011 (Not released yet) and with this listener:
 

local function onToggle( event ) print("Pressed Button: " .. tostring( event.target:getText() ) ) print("Is pressed ?= " .. tostring( event.target:pressed() ) ) print( "SSK VERSION: " .. ssk.getVersion() ) end

I get this output:

09:37:09.501 Pressed Button: Hello 09:37:09.501 Is pressed ?= true 09:37:09.501 SSK VERSION: 2017.011 09:37:10.222 Pressed Button: Hello 09:37:10.222 Is pressed ?= false 09:37:10.222 SSK VERSION: 2017.011

As well, the color toggles between white and grey.

OK, let me take a look at the current changes and make a quick update.

I’ll post back here and make an announcement when it is released.

Note: I know that I did fix an issue with this type of toggle button.  Images were working fine, but filled rectangles didn’t toggle properly.

I thought I released this in 010, but obviously I did not.

The source of this bug is an update I did months ago adding an additional optional visual state to support using graphics to show a disabled button.

-Ed

https://forums.coronalabs.com/topic/69839-ssk2-updated-2017011-released/

Thanks a lot,

It still seems to ignore the toggled* parameters but the (un)sel* ones work great now and do what I needed.

Bugger.

It looks like the ‘locked’ and ‘toggled’ code has going MIA in the library.

I’ll have to dig through prior commits and see if I can find when this occurred.

For now, ONLY sel* and unsel* params are available.

OK.  Here is the deal.  

Early this year or late last year I introduced the ability to have 2, 3, and 4 state button art.  This allowed you to use collections of art that had locked and special toggled images.

This all works fine.

Then, I went to add reciprocal filled rectangles to keep the feature set even and ran into an issue.  It seems I never went back to fix that issue.

Sadly I must give you this advice.  Stick to sel* and unsel* only for now.  Till I have a chance to revisit 3 and 4 state buttons this may not work as expected.

Fixed.  Go get 2017.012:

https://github.com/roaminggamer/SSK2/

I also added a new validation test to test the filled rect versions of 2, 3, and 4 state buttons side-by-side.

Turns out the code was all there, just missing a logic check.

Thanks again and sorry for causing trouble,

Works as documented now - unselected, selected, and toggled.

No need to apologize.  I thought I’d fixed it and I was wrong.  I’m glad it is good to go now.

What version of SSK2 are you running?

https://roaminggamer.github.io/RGDocs/pages/SSK2/#are-you-using-the-latest-version

Sorry, forgot to add it:

version is  2017.010

I’m running 2017.011 (Not released yet) and with this listener:
 

local function onToggle( event ) print("Pressed Button: " .. tostring( event.target:getText() ) ) print("Is pressed ?= " .. tostring( event.target:pressed() ) ) print( "SSK VERSION: " .. ssk.getVersion() ) end

I get this output:

09:37:09.501 Pressed Button: Hello 09:37:09.501 Is pressed ?= true 09:37:09.501 SSK VERSION: 2017.011 09:37:10.222 Pressed Button: Hello 09:37:10.222 Is pressed ?= false 09:37:10.222 SSK VERSION: 2017.011

As well, the color toggles between white and grey.

OK, let me take a look at the current changes and make a quick update.

I’ll post back here and make an announcement when it is released.

Note: I know that I did fix an issue with this type of toggle button.  Images were working fine, but filled rectangles didn’t toggle properly.

I thought I released this in 010, but obviously I did not.

The source of this bug is an update I did months ago adding an additional optional visual state to support using graphics to show a disabled button.

-Ed

https://forums.coronalabs.com/topic/69839-ssk2-updated-2017011-released/

Thanks a lot,

It still seems to ignore the toggled* parameters but the (un)sel* ones work great now and do what I needed.

Bugger.

It looks like the ‘locked’ and ‘toggled’ code has going MIA in the library.

I’ll have to dig through prior commits and see if I can find when this occurred.

For now, ONLY sel* and unsel* params are available.

OK.  Here is the deal.  

Early this year or late last year I introduced the ability to have 2, 3, and 4 state button art.  This allowed you to use collections of art that had locked and special toggled images.

This all works fine.

Then, I went to add reciprocal filled rectangles to keep the feature set even and ran into an issue.  It seems I never went back to fix that issue.

Sadly I must give you this advice.  Stick to sel* and unsel* only for now.  Till I have a chance to revisit 3 and 4 state buttons this may not work as expected.