Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
helex
Posts: 275
Registered: ‎02-14-2012
My Device: Nokia N950 / BB Playbook
My Carrier: -
Accepted Solution

Setting a RGB value to a Color

 

How could I set a RGB value to a color property?

 

The fromARGB() value seems not accessible from inside Cascades.

 

In detail: I have a TextArea inside a ListView:

 

TextArea {
	text: ListItemData.Text
	textStyle {
		fontWeight: FontWeight.Bold
		color: Color.Red 
	}
	editable: false
	backgroundVisible: false
	touchPropagationMode: TouchPropagationMode.None
}

I would like to set a specific color for each list item.

 

At pure qml (maemo, symbian and MeeGo) I cold simply set the color this way:

color: "#ff0010"

This way I could use simpy a string in my datamodel with the color I would like.

 

But this doesn't work in Cascades.

 

Any ideas how to store and display the text in different colors?

 

Please use plain text.
Developer
shahumang8
Posts: 581
Registered: ‎08-09-2010
My Device: Not Specified

Re: Setting a RGB value to a Color

[ Edited ]

Hello,

  

      You can set the RGB color like this :- 

 

                         Color.create("#00ffff")  and also you can write like  Color.create(10,10,10)

      

 TextArea {
            text: "Testing"
            textStyle {
                fontWeight: FontWeight.Bold
                color: Color.create("#00ffff")
            }
            editable: false
            backgroundVisible: false
            touchPropagationMode: TouchPropagationMode.None
        }

 

-------------------------------------------------------------------------------------------------------------------------------

 

feel free to press the like button on the right side to thank the user that helped you.

Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Setting a RGB value to a Color

One thing to not if that doing Color.create(r,g,b) each value needs to be a decima/float value of some number divided by 255.0

Like all of my posts
Please use plain text.
Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

Re: Setting a RGB value to a Color

create(r, g,b,a) or create(r,g,b) function must always take the value of r,g,b,a components in range [0,1] .

Always Success
Please use plain text.
Developer
helex
Posts: 275
Registered: ‎02-14-2012
My Device: Nokia N950 / BB Playbook
My Carrier: -

Re: Setting a RGB value to a Color

Thanks a lot. Works great! :smileyhappy:

 

Sometimes it is so simple. If I had only more time to develop for BB10...

Please use plain text.