Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Text Color
Started by DLuck Jan 26 2019 04:22 PM

2 replies to this topic
change color

Best Answer roaminggamer , 26 January 2019 - 06:37 PM

You can't change the label color of a Widget button post-creation.

 

You'll need to

  • create your own custom button library, - OR - 
  • extend widget.* (source code available on github), - OR - 
  • dig into the object (not suggested) and find the handle to the label, - OR - 
  • use a library that supports this feature like SSK2.

 

i.e. In SSK, this would be as easy as:

// SSK push button
local button = easyIFC:presetPush( nil, "default", 100, 100, 50, 40, "Hello" )

button:setLabelColor( 1, 0, 0)

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

DLuck

[GLOBAL: userInfoPane.html]
DLuck
  • Enthusiast

  • 70 posts
  • Corona SDK

Hello, 

 

I can't figure out how to change the "Label Color" text color. I tried object:setTextColor( r, g, b ), then button1:setTextColor(), label:setTextColor().

I stuck them just about everywhere. All I get are errors.

display.setStatusBar(display.HiddenStatusBar)

local widget = require( "widget" )

local bgSky = display.newImageRect( "bgSky.png", 600, 400 )
bgSky.x = display.contentCenterX
bgSky.y = display.contentCenterY


local function handleButtonEvent( event )
 
    if ( "ended" == event.phase ) then
        print( "Button was pressed and released - Label Color" )
    end
end
 

local button1 = widget.newButton(
    {
        label = "button",
        onEvent = handleButtonEvent,
        emboss = false,
        shape = "roundedRect",
        width = 200, 
        height = 40,   
        cornerRadius = 20,  
        fillColor = { default={0,0,0,1}, over={0,0,255,1} },  
        strokeColor = { default={0,0,255,1}, over={0,0,0,1} },
        strokeWidth = 4    
    }
)
 

button1.x = display.contentCenterX
button1.y = display.contentCenterY - 60
 

button1:setLabel( "Label Color"  )

Appreciate any help, 

 

Thanks



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,508 posts
  • Corona SDK

  Best Answer

You can't change the label color of a Widget button post-creation.

 

You'll need to

  • create your own custom button library, - OR - 
  • extend widget.* (source code available on github), - OR - 
  • dig into the object (not suggested) and find the handle to the label, - OR - 
  • use a library that supports this feature like SSK2.

 

i.e. In SSK, this would be as easy as:

// SSK push button
local button = easyIFC:presetPush( nil, "default", 100, 100, 50, 40, "Hello" )

button:setLabelColor( 1, 0, 0)

  • agramonte and DLuck like this

[TOPIC: post.html]
#3

DLuck

[GLOBAL: userInfoPane.html]
DLuck
  • Enthusiast

  • 70 posts
  • Corona SDK

Great. Thanks for helping me.


[topic_controls]
[/topic_controls]