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!