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

Adobe AIR Development

Reply
Contributor
Posts: 22
Registered: ‎01-28-2011
My Device: Not Specified

Set colour on ButtonLabel

Getting down to the wire!

 

Probably a simple question but I googled and searched forum and couldn't find out how to do this. I'm trying to set the colour of a LabelButton but can't seem to do it.

 

I tried:

 

            addButton.cacheAsBitmap = true;
            addButton.opaqueBackground = 0x99CCFF;      

But that only sets the colour behind the button and not the button.

 

Do I need to do skinning or using graphic drawing? I figured there must be an easy way to set button colour!

 

Thanks.

 

 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Set colour on ButtonLabel

Try this:

 

var enter_format : TextFormat = new TextFormat( null, 26, 0x2CB830, true );

this.keypad_enter.setTextFormatForState( enter_format, SkinStates.DOWN );
this.keypad_enter.setTextFormatForState( enter_format, SkinStates.SELECTED );
this.keypad_enter.setTextFormatForState( enter_format, SkinStates.UP );

 

Contributor
Posts: 22
Registered: ‎01-28-2011
My Device: Not Specified

Re: Set colour on ButtonLabel

I am able to change the colour of the text and font size, etc. which will be useful but I don't see how to set the background colour of the button. I probably didn't specify that in my original post.

 

I took your code and did the following. format.color is the text color and I didn't see an attribute for background color. Probably something to do with transparency?

 

    var format : TextFormat = new TextFormat();
            format.color = 0x2CB830;
            format.size = 25;
            format.bold = true;      
            
            addButton.setTextFormatForState( format, SkinStates.DOWN );
            addButton.setTextFormatForState( format, SkinStates.SELECTED );
            addButton.setTextFormatForState( format, SkinStates.UP );
       

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Set colour on ButtonLabel

hey chilllybin,

 

to alter the look of a labelbutton and its background, you have to create a custom skin for it. to do that, here is a page from the Development Guide that shows you a step by step way:

 

http://docs.blackberry.com/en/developers/deliverables/23959/Skinning_your_UI_components_1446808_11.j...

 

hope that clears things up for ya. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Contributor
Posts: 22
Registered: ‎01-28-2011
My Device: Not Specified

Re: Set colour on ButtonLabel

Ah...thanks JRab. I wasn't going to delve into skinning until I got all the basic functionality of the app going but sometimes I get side-tracked and want to make the app prettier. Back to work on the functionality...

 

Thanks jtegen as well for your help - that will come in handy later on.

Both you guys are awesome and are a big help.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Set colour on ButtonLabel

Hey ChillyBin,

 

this is a follow up to your skinning question. I know you didnt ask for it but i had some free time and thought this would be an good add to the PlayBook Wiki Site. I wrote up a step by step (mostly) of how to create your own skin and included project files and PSD for it. hopefully it can help some people out that want to create their own custom button:

 

http://playbookwiki.org/index.php/Skinning_A_LabelButton_Object

 

If you guys ever want to add something either send @willyyr a PM or me a PM and we'll upload it for you or he can create an account for you. Hopefully we will be able to build a big enough library for everyone to use. Good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Contributor
Posts: 22
Registered: ‎01-28-2011
My Device: Not Specified

Re: Set colour on ButtonLabel

Nice write-up on skinning, JRab. I can see that being useful to create a more interesting looking app.

 

But if I just want to change the colour of a LabelButton, is there no easier way of doing that other than creating one's own button image .png?

 

I often want to highlight a button in a slightly different colour to call attention to it.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Set colour on ButtonLabel

unfortunately all the skinning is done via embedded images. if you can find someway to alter the color there might be a way. ive seen things on colortransform that might help too. but not too sure. here is a link to a thread dealing with that here:

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Invert-the-colours-of-a-graphic-o...

 

not too sure i havent dabbled in that just yet but sounds logically fitting. let me know how it works out. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman