Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

SSK2: Toggle buttons ignore the "toggled*" parameters
Started by gsimeonov Aug 06 2017 08:23 AM

11 replies to this topic

Best Answer roaminggamer , 06 August 2017 - 03:27 PM

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.

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

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! 


[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

[TOPIC: post.html]
#3

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

Sorry, forgot to add it:

 

version is 2017.010



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

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



[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

[TOPIC: post.html]
#7

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

Thanks a lot,

 

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



[TOPIC: post.html]
#8

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

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.



[TOPIC: post.html]
#9

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

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.



[TOPIC: post.html]
#10

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

  Best Answer

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.


Edited by roaminggamer, 06 August 2017 - 03:28 PM.


[TOPIC: post.html]
#11

gsimeonov

[GLOBAL: userInfoPane.html]
gsimeonov
  • Enthusiast

  • 43 posts
  • Corona SDK

Thanks again and sorry for causing trouble,

 

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



[TOPIC: post.html]
#12

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,489 posts
  • Corona SDK

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




[topic_controls]
[/topic_controls]