Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

2013.2076 Widgets 2.0 Button issues with setFillColor
Started by usa.pedro Nov 27 2013 09:08 AM

20 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

usa.pedro

[GLOBAL: userInfoPane.html]
usa.pedro
  • Starter
  • Pip
  • 7 posts
  • Newbie

Before this  release  (2013.2076) I was creating widgets 2.0 buttons in my app , and changing their color using setFillColor() . Everything was working fine, buttons looked like this 

2k3a1f.jpg

 

but after the update the text is now covered by the filling color

vs2DXWy.jpg?1

 

when I touch the button and release it , then it looks as it should (the text becomes white and border darker).

 

this is the code I am using :

 

playBtn = widget.newButton{
        label="Play Now",
        labelColor = { default={255}, over={128} },
        emboss = true,
        width=154, height=40,
        onRelease = onPlayBtnRelease
    }
playBtn:setFillColor( 34, 140, 35 )
 
 
Is this a bug introduced in this release? Is there a solution for it?
Thanks in advance for your help!
 


[TOPIC: post.html]
#2

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Enterprise
  • PipPipPipPipPipPip
  • 2,147 posts
  • Jedi

Color values with Graphics 2.0 need to be in the 0.0 to 1.0 range (no more 0 to 255).

One quick way to change your colors in older projects would be to add "/255" to all color values.
Like: playBtn:setFillColor( 34/255, 140/255, 35/255 )

Remember to go through your whole project and change all color values you find.

[TOPIC: post.html]
#3

usa.pedro

[GLOBAL: userInfoPane.html]
usa.pedro
  • Starter
  • Pip
  • 7 posts
  • Newbie

Thanks for the reply but changing the values to numbers  from 0.0 to 1.0 did not solved the issue.

In fact the using values from 0 to 255 does changes the color of the button, but does not bring the text to front until the button is touched, to solve the problem I simulated the touch to the button on loading the scene and that worked fine, but this is kind of "hack solution". There is an inconsistency in the behavior, setFillColor() changes the color of the button including the text, but touching the button brings the text to front excluding it from being overlay-ed by the color (which is the behavior i expected from the beginning)



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Corona Staff
  • 9,318 posts
  • Jedi

I believe this is a bug related to the fact that text objects now use :setFillColor as well, where in G1.0, it was :setTextColor.  Please produce a small sample (create a new button, then call setFillColor()) and file a bug report using the "Report a Bug" link at the top.  We need this in the bug tracker so Engineering can work on it.

 

Thanks

Rob



[TOPIC: post.html]
#5

dionny

[GLOBAL: userInfoPane.html]
dionny
  • Starter
  • Pip
  • 5 posts
  • Newbie

I took a look at https://github.com/coronalabs/framework-widget/blob/master/widgetLibrary/widget_button.lua

Line 1069 is the cause of this issue.

 

Fixed it on my end as follows:

function button:setFillColor( ... )		
		for i = self.numChildren, 1, -1 do
			if "function" == type( self[i].setFillColor ) then
				if(self[i]._isLabel ~= true) then
					self[i]:setFillColor( ... )
				end
			end
		end
	end


[TOPIC: post.html]
#6

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Any news on that? This bug is still happening on daily build 2162.

 

And, on the daily build 2171 and 2174 the setFillColor stopped worked at all (submitted bug #30390 )



[TOPIC: post.html]
#7

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Any news on that? Is has been almost 3 months...



[TOPIC: post.html]
#8

usa.pedro

[GLOBAL: userInfoPane.html]
usa.pedro
  • Starter
  • Pip
  • 7 posts
  • Newbie

Unfortunately, it seams it is not going to get fixed, this is the reply I got :

"

Re: (Case 28509) 2013.2076 Widgets 2.0 Button issues with setFillColor

Hi there,


Unfortunately, this is not a bug, but a widget library limitation. We'll be adding the setFillColor property as it was on the V1 version of the widget library in the near future though.

Thanks for the report, and a great day,



Alex"

 

In my opinion inconsistent behavior is a bug, therefore this is a bug.



[TOPIC: post.html]
#9

jstrahan

[GLOBAL: userInfoPane.html]
jstrahan
  • Pro
  • PipPipPipPipPipPip
  • 1,922 posts
  • Jedi

not sure if same as 1.0 but could try

myButton._view._label:toFront()

where mybutton is the name of your button
I'm not at computer so can't be sure if still will work or if it's been changed a bit or completely

[TOPIC: post.html]
#10

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Definitively a bug...



[TOPIC: post.html]
#11

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Just tested here the fillColor and now it is not working one more, not even the background is being filled...

 

This code below worked on build 2162 but now not works any more.

local widget = require "widget"
widget.setTheme( "widget_theme_ios" )
local b = widget.newButton{ label="Red Button" }
b:setFillColor(1,0,0)


[TOPIC: post.html]
#12

Brent Sorrentino

[GLOBAL: userInfoPane.html]
Brent Sorrentino
  • Corona Staff
  • 4,240 posts
  • Jedi

Hi Renato,

The "b" in your code is a table of various objects that make up the button, so you can't fill it directly. Are you attempting to set the label color post-declaration? 

 

Thanks,

Brent



[TOPIC: post.html]
#13

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Hi Brent.

 

No, I am trying to change the background color of the button (That on last time, it was filling the label also). That command used to work before....

 

Danny had taught me that while ago (http://forums.coronalabs.com/topic/32943-change-widget-button-background-color/).



[TOPIC: post.html]
#14

Brent Sorrentino

[GLOBAL: userInfoPane.html]
Brent Sorrentino
  • Corona Staff
  • 4,240 posts
  • Jedi

Hi Renato,

What kind of button are you seeking to make? An iOS7 style? Of course those don't have backgrounds. Or, are you trying to "tint" an image used for a button?

 

Brent



[TOPIC: post.html]
#15

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

I am using the former iOS theme..

widget.setTheme( "widget_theme_ios" )

Just want to fill it with a color different than the default gray.

 

 

When Graphics 2.0 was released setFillColor worked fine to fill the button background.

Then, it started filling not only the background but also the label (the first post of this thread).

Now, setFillColor does not work at all.



[TOPIC: post.html]
#16

Brent Sorrentino

[GLOBAL: userInfoPane.html]
Brent Sorrentino
  • Corona Staff
  • 4,240 posts
  • Jedi

Are you going for an iOS6 style button? The one with the "button look" ?



[TOPIC: post.html]
#17

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Yes, I use them inside a game (image attached).

 

I think that the iOS 7 button style does not provide a good UI to use inside games.

 

The default iOS 6 button is great because it is a simply way to create a regular button with Corona without having to have a button image.

 

 

 

 

Attached Files



[TOPIC: post.html]
#18

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,674 posts
  • Jedi

Still no way to use setFillColor to re-tint a 9-Slice button right?



[TOPIC: post.html]
#19

Brent Sorrentino

[GLOBAL: userInfoPane.html]
Brent Sorrentino
  • Corona Staff
  • 4,240 posts
  • Jedi

Using :setFillColor() on 9-slice buttons is fixed in build #2295 (or perhaps one build earlier).



[TOPIC: post.html]
#20

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,674 posts
  • Jedi

Just as I gave up and make 6 different colors of my button... Oh well. Better late than never. :)

 

Thanks much!!!



[TOPIC: post.html]
#21

Renato - Red Beach

[GLOBAL: userInfoPane.html]
Renato - Red Beach
  • Pro
  • PipPipPipPipPipPip
  • 811 posts
  • Jedi

Just tested here (build 2289) and it is working. Thanks Brent.

 

You can close my bug report about that (#31816 from 4/4/14)




[topic_controls]
[/topic_controls]