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

Java Development

Reply
Developer
spiv
Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified
Accepted Solution

Get system focus/theme color

[ Edited ]

Hi,

 

I want to highlight the text of a CheckboxField with the system focus/highlight/theme color. I know that I could retrieve foreground and background color easily from the Graphics but is there a way to get the system focus/highlight/theme color ?

 

Today, I have this code but the rendering is quiet ugly (black & white) :

 

CheckboxField cbField = new CheckboxField("test", true) {
protected void paint(Graphics g) {
if(this.isFocus()) {
int fcolor = g.getColor();
int bcolor = g.getBackgroundColor();
g.setColor(fcolor);
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 8, 8);
g.setColor(bcolor);
}
super.paint(g);
}

};
add(cbField);

 

 

Regards,

 

Sylvain.

Message Edited by spiv on 10-28-2008 10:48 AM
Please use plain text.
Administrator
MSohm
Posts: 14,446
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Get system focus/theme color

These colours are not currently exposed in the BlackBerry API set.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
spiv
Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified

Re: Get system focus/theme color

It's a pitty :smileywink:

 

Thx.

Please use plain text.
New Developer
twilightbella
Posts: 2
Registered: ‎02-26-2009
My Device: Curve 8900

Re: Get system focus/theme color

I'm aware that I'm a tad behind the times... Anyway I was searching relentlessly to find a way to get the theme highlight color for my application, anddd I came up with this (after I gave up on googling and started looking through the api documentation):

http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/Field.html

protected final void drawHighlightRegion(Graphics graphics,
                                         int style,
                                         boolean on,
                                         int x,
                                         int y,
                                         int width,
                                         int height)

 

I noticed in your code that you're trying to draw a rounded highlight region, so this wouldn't directly help obviously, but don't forget you can always draw over it (aka maybe draw the background over the circle-ness on each side.

 

Anyway hope I helped, I found your post during my googling-ness a few days ago, so I figured I'd go back and reply.

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Get system focus/theme color

So is there a work-around way to getting these colors?

Please use plain text.