Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Update button widget text color.
Started by leojharris Aug 24 2018 05:22 PM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

leojharris

[GLOBAL: userInfoPane.html]
leojharris
  • Observer

  • 19 posts
  • Corona SDK

Hi all,

 

I want to update the button text color, not the fill or stroke I found methods for that but cant find any methods for setting the button text color after initialization, I'm trying to do something like this: 

btn:setLabelColor(1,1,1,0)

I get an issue calling this:

btn:setLabelColor()

but calling these are fine

 

btn:setStrokeColor( 1, 1, 1,0 )
btn:setFillColor( 1, 1, 1,0 )
 
And in the constructor of the btn we can set 
 
..
fillColor = { default={ 127/255, 127/255, 127/255 , 0.3 }, over={ 1, 0.2, 0.5, 0.5} },
labelColor = { default={ 82/255,241/255,12/255  }, over={ 82/255,241/255,12/255, 1 } },
strokeColor = { default={82/255,241/255,12/255,1}, over={82/255,241/255,12/255 ,1} },
...
 
but nothing to set label color after init?
 

 



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 291 posts
  • Corona SDK

setStrokeColor() and setFillColor() are general functions for changing the stroke or fill color of text and vector objects, so they work after an object has been created. labelColor is an optional parameter for when you create buttons using the widget, so it does not work after the object has been created.

You can find how the widget works here: https://github.com/coronalabs/framework-widget.

I personally create buttons and text separately. That way I better customise the fonts as well as better control them afterwards.




[topic_controls]
[/topic_controls]