setEmbossColor Widget Button Text

Hi,

Is it possible to set the colour of the embossed text on a button as you can with display.newText?

I’ve tried specifying the colours as part of the button widget options but it either gets ignored or throws an error.

I can revert to using text over an image but thought using widget button would be easier.

Thanks

Dean

Hi Dean,

Does setting the label color not apply if the “emboss” option is true? I don’t use embossed text personally (just a matter of taste) so I’m not familiar with how it works on widget buttons.

Brent

Hi,

This is what I’ve tried to do but this throws a runtime error SetEmbossColor a nil value.

I’ve tried putting the highlight and shadow values in the Options table but they just get ignored.

local hangerButtonOptions = {

    label = “button”,

    onRelease = gotoHanger,

    font = themeFont,

    fontSize = 14,

    labelColor = { default={ 1, 1, 1 }, over={ 1, 1, 1, 0.5 } },

    emboss = true,

    --properties for a rounded rectangle button…

    shape=“roundedRect”,

    width = 100,

    height = 26,

    cornerRadius = 6,

    fillColor = { default={ 0.85, 0.2, 0.13, 1 }, over={ 1, 0.1, 0.7, 0.4 } },

    strokeColor = { default={ 1, 1, 1, 1 }, over={ 0.8, 0.8, 1, 1 } },

    strokeWidth = 2,

    isVisible = true

}

hangerButton = widget.newButton( hangerButtonOptions) hangerButton.x = display.contentCenterX hangerButton.y = display.contentCenterY + 130 hangerButton:setLabel( “HANGER” )

embossColour =

    {

        highlight = { r=0.85, g=0.2, b=0.13 },

        shadow = { r=0, g=0, b=0 }

    }

hangerButton:setEmbossColor( embossColour )

Any advice?

Dean

Hi Dean,

The solution for this is to target the actual text element of the button, not the overall button itself. This element is accessible by digging down a bit into the button hierarchy:

[lua]

hangarButton._view._label

[/lua]

Using the “setEmbossColor()” API on that should accomplish what you need.

Take care,

Brent

Hi Dean,

Does setting the label color not apply if the “emboss” option is true? I don’t use embossed text personally (just a matter of taste) so I’m not familiar with how it works on widget buttons.

Brent

Hi,

This is what I’ve tried to do but this throws a runtime error SetEmbossColor a nil value.

I’ve tried putting the highlight and shadow values in the Options table but they just get ignored.

local hangerButtonOptions = {

    label = “button”,

    onRelease = gotoHanger,

    font = themeFont,

    fontSize = 14,

    labelColor = { default={ 1, 1, 1 }, over={ 1, 1, 1, 0.5 } },

    emboss = true,

    --properties for a rounded rectangle button…

    shape=“roundedRect”,

    width = 100,

    height = 26,

    cornerRadius = 6,

    fillColor = { default={ 0.85, 0.2, 0.13, 1 }, over={ 1, 0.1, 0.7, 0.4 } },

    strokeColor = { default={ 1, 1, 1, 1 }, over={ 0.8, 0.8, 1, 1 } },

    strokeWidth = 2,

    isVisible = true

}

hangerButton = widget.newButton( hangerButtonOptions) hangerButton.x = display.contentCenterX hangerButton.y = display.contentCenterY + 130 hangerButton:setLabel( “HANGER” )

embossColour =

    {

        highlight = { r=0.85, g=0.2, b=0.13 },

        shadow = { r=0, g=0, b=0 }

    }

hangerButton:setEmbossColor( embossColour )

Any advice?

Dean

Hi Dean,

The solution for this is to target the actual text element of the button, not the overall button itself. This element is accessible by digging down a bit into the button hierarchy:

[lua]

hangarButton._view._label

[/lua]

Using the “setEmbossColor()” API on that should accomplish what you need.

Take care,

Brent