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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Visitor
jacklearnbb
Posts: 1
Registered: ‎07-07-2010
My Carrier: abc
Accepted Solution

Focus rectangle

hi,

 

New to blackberry development.I have seen that when I focus on any icon within my application, it gets surrounded by a blue rectangle filling the surrounding portions.

 

1) Can I change this color to some other ?

 Or,

2) if a direct change of color is not possible ,Can I place that custom colored rectangle as an image under the icon and write appropriate methods on focus and unfocus?

 

Suggestions needed on required code to do the same.

 

TIA

Please use plain text.
Developer
simon_hain
Posts: 13,817
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Focus rectangle

welcome to the support forums.

 

the focus/highlighting is controlled by this method:

 http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/Field.html#drawFocus(net.rim.device.api.ui.Graphics, boolean)

 

if you want to have a different image on focus you could overwrite drawFocus empty and change the bitmap of a bitmapfield onFocus/onUnFocus.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
TobiasReaper
Posts: 85
Registered: ‎05-03-2010

Re: Focus rectangle

Hi Jack,

Welcome to the forums. Do take a look at the link provided by Simon. There are various ways to manipulate the focus, here's one that's not neccessarily the one you want but you get the idea.

 

 

protected void drawFocus(Graphics graphics,boolean on) {

XYRect rect = new XYRect();
getFocusRect(rect);
graphics.setColor( Color.RED);
graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
graphics.setColor(Color.ORANGE);
graphics.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, true);
drawHighlightRegion(graphics, Field.HIGHLIGHT_SELECT, false, rect.x, rect.y, rect.width, rect.height);
}

Cheers.

 

Please use plain text.