I’ve created a widget button and assigned color to it as part of its creation. I have no problems setting the color during the creation. eg.
local myButton = widget.newButton(
{
id="myBtn",
label="originalText",
onEvent = changeMyColor,
shape="rect",
fillColor={ default={1,0,0}, over={1,0,0,0.5} },
strokeColor={ default={1,0,0}, over={1,0,0,0.5} },
strokeWidth=1,
width=100,
height=50,
x=display.contentCenterX,
y=display.contentCenterY,
}
)
On a touch event, I would like to call a function that changes the text and the color for the widget. I have no problems changing the text using event.target:setLabel("[newTextHere]")
. However, setFillColor doesn’t seem to work. It always changes the fill color to black.
eg.
local function changeMyColor(event)
event.target.setLabel("NewText")
event.target:setFillColor({ default={0,1,0}, over={0,1,0,0.5} })
end
After this function is called, the text changes as expected, but the fill color becomes black, despite the values representing green.
Any advice welcome.