Change button color when pressed

I would like to change the color of a button to give the feedback that it has been Activated:

local btn = Widget.newButton( {        shape = "roundedRect",         strokeColor = { default={211 /255, 84 /255, 0 /255}, over={0.2,0.2,1,1} },         strokeWidth = 2,         fillColor = { default={1,0,0}, over={0,0,0} },         onRelease = btnPressed } )

After I click the button, the code below doesn’t run unless I create the button without the “fillColor” property assigned. Now, I don’t care for the “over” part of it, but, I would like to give it a starting color. But, when I remove the “over” part, it gives me an error.

local function btnPressed( event )     local btn = event.target       btn:setFillColor( 0,1,0 ) end

Am I missing something here?

@Abdo23 If you don’t need fillColor property assigned then just leave it out and just assign it after the button is created. I hope I understood your question correctly.

local function btnPressed( event )     local btn = event.target       btn:setFillColor( 0,1,0 ) end local btn = Widget.newButton( {        shape = "roundedRect",         strokeColor = { default={211 /255, 84 /255, 0 /255}, over={0.2,0.2,1,1} },         strokeWidth = 2,         -------REMOVE---------------------\> fillColor = { default={1,0,0}, over={0,0,0} },         onRelease = btnPressed } ) btn:setFillColor(1, 0, 0)  --\> ADD

Yes, this is a very viable solution, however, I use a separate library for my UI elements, I use that same button code in multiple places with its default and over colors, only one place in my app is where I need the button to have a different color.

I guess I will just write a separate code for that button.

@Abdo23 If you don’t need fillColor property assigned then just leave it out and just assign it after the button is created. I hope I understood your question correctly.

local function btnPressed( event )     local btn = event.target       btn:setFillColor( 0,1,0 ) end local btn = Widget.newButton( {        shape = "roundedRect",         strokeColor = { default={211 /255, 84 /255, 0 /255}, over={0.2,0.2,1,1} },         strokeWidth = 2,         -------REMOVE---------------------\> fillColor = { default={1,0,0}, over={0,0,0} },         onRelease = btnPressed } ) btn:setFillColor(1, 0, 0)  --\> ADD

Yes, this is a very viable solution, however, I use a separate library for my UI elements, I use that same button code in multiple places with its default and over colors, only one place in my app is where I need the button to have a different color.

I guess I will just write a separate code for that button.