Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

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

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


[GLOBAL: userInfoPane.html]
  • 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: 


I get an issue calling this:


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]

XeduR @Spyric

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

  • 619 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.