Jj Tuibeo
Jj Tuibeo

Reputation: 773

How to change the highlighter(blue) in a blackberry application?

The default highlight color in blackberry is blue. I'm currently doing an application which dominant color is red. Is there a way to change the highlighter color to red? I googled it and find a solution for the ListField, how about for other fields like buttons, textFields, bitmapFields etc...?

Upvotes: 1

Views: 198

Answers (2)

Jj Tuibeo
Jj Tuibeo

Reputation: 773

Found this implementation in the blackberry forum, have tried it and it works perfectly. But you need to override this method for each fields that you want to have a different highlighter.

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 color here*/);    
    g.setColor( 0xFFFFFF );    
    g.clear();                
    this.paint( g );                
    g.popContext();
}

Upvotes: 3

Mister Smith
Mister Smith

Reputation: 28168

You can override Field.drawFocus for your custom fields:

protected void drawFocus(Graphics g, boolean on) {
    // Custom focus painting
}

Upvotes: 2

Related Questions