Question

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...?

Was it helpful?

Solution

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();
}

OTHER TIPS

You can override Field.drawFocus for your custom fields:

protected void drawFocus(Graphics g, boolean on) {
    // Custom focus painting
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top