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
sandeepkumar03
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified
Accepted Solution

Change default selection highlight color

Hi All,

 

Is it possible to change the default selection color (Blueish) to some other color?

 

Thanks,

Sandeep

Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Change default selection highlight color

[ Edited ]

Hi,

 

 You can not change the selection color.

 

 This selection is same on emulators i.e blue  but on device it can differs from pink to blue to yellow plus I guess it depends upon the theme

set on phone.

 

You can do one thing you can override the paint of that particular component and change the focus color.

 

May be this will help you. 

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=12904&query.id=99...

 

 

Message Edited by Rajat_10Sep on 04-03-2009 01:04 PM
Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Change default selection highlight color

Hi Sandeep,

 

Yes you can change the default selection color in listField and that to without overriding paint method.

 

As I found out in other thread related to ListField.

 

Here is the link of that thread

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=23633&query.id=24...

 

just include <listField instance>.invalidate(<index>);

 

as the last line of your drawListRow().

 

This will help you in changing the color of selection in listField.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
pwerry
Posts: 177
Registered: ‎01-21-2009
My Device: 9900

Re: Change default selection highlight color

[ Edited ]

Allow me to take this a step further. You can mimic the way it is done natively at the java layer. It will be a bit slower, but it is not noticable. Check it out:

 

 

protected void drawFocus( Graphics g, boolean on )

{

XYRect focusRect = new XYRect();

getFocusRect( focusRect );

int yOffset = 0;

 

if ( isSelecting() )

{

yOffset = focusRect.height >> 1;

focusRect.height = yOffset;

focusRect.y += yOffset;

}

g.pushRegion( focusRect.x, focusRect.y, focusRect.width, focusRect.height, -focusRect.x, -focusRect.y );

g.setBackgroundColor( YOUR_DESIRED_COLOR );

g.setColor( 0xFFFFFF );

g.clear();

this.paint( g );

g.popContext();

}

 

*Note: Sometimes this editor butchers my code inserts. Will edit if it looks bad. 

 

Yep it messed up the code insert. Does anyone know why? Maybe it doesn't like the newlines from the JDE? 

 

Message Edited by pwerry on 04-06-2009 12:51 PM
New Contributor
shawnmack
Posts: 2
Registered: ‎08-27-2010
My Device: 9700

Re: Change default selection highlight color

Excellent fix for the highlighting color!  Used this for the BitmapField and it worked flawlessly.

 

Thanks!

Regular Visitor
Luis_100
Posts: 1
Registered: ‎01-10-2011
My Device: Curve 9300

Re: Change default selection highlight color

Excellent solution. I just don't understand why the scroll values are negative...

 

Do you know why?

 

Thanks!