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
ryandevore
Posts: 46
Registered: ‎07-12-2008
My Device: Not Specified

Theme independent ButtonFields

Is there a built in way to create a ButtonField object that does not follow the current theme of the Blackberry?  I've had no luck so far in trying to override methods in ButtonField. 

 

I thought this might work:

protected void drawFocus(Graphics graphics, boolean on) { XYRect focusRect = new XYRect(); getFocusRect(focusRect); graphics.setGlobalAlpha(150); graphics.setColor(0x00AA00000); graphics.fillRect(focusRect.x, focusRect.y, focusRect.width, focusRect.height); }

But it only draws the red rectangle around the text of the button.  On my current device (ATT Curve with ATT theme), the whole button is a larger orange rounded rectangle.

 

I know that I can solve this by rolling a fully custom Field class, but I'm fishing to see if there might be an easier way to do this.

 

I also tried experimenting with the paint() method, and I don't seem to be able to get the full extent of the button field.  Both getWidth and getPreferredWidth only give me the region directly around the text, and don't include the padded areas.  If I could somehow get at the actual size of the button, my efforts at custom painting might be easier.

 

Thanks for any help!

 

Ryan

 

Please use plain text.
Developer
simon_hain
Posts: 15,869
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Theme independent ButtonFields

imo creating your own field is a lot easier in this case.
in most cases i use a modified bitmapfield as a "button" anyhow.
----------------------------------------------------------
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.