I'm not entirely sure what you mean by "it is firing an event on focus change." Isn't that what you want?
I worked on a custom Bitmap button last month, and ended up creating a subclass of Field, and handling the drawing myself. I don't remember why a subclass of BitmapField didn't work, but you might want to look at that. You would have a little more control.
In addition, you need to add calls to invalidate()
in your onFocus
and onUnFocus
methods, because this will cause the field to be repainted with the new Bitmap. Finally, think about overriding drawFocus()
and doing nothing inside that method, because this will prevent the drawing of the standard focus style (a blue halo). Unless you want that, but if you have your own focus image it might be undesirable.
If you post some more details about the problem I can try to help, but I am not sure what the issue is.
Edited to add:
I took a look at my notes and found this link,
http://www.thinkingblackberry.com/archives/167
and on second look, there is a custombuttonsdemo in the samples\com\rim\samples\device\ directory of the BB JDE 5.0. It implements basically exactly what that blog post describes, it might be helpful. That blog post describes drawing a custom button, not using a Bitmap, but it's the same idea. In the paint(Graphics g)
method you would do
protected void paint(Graphics g) {
g.drawBitmap(0,0,getWidth(),getHeight(),bmp,0,0);
}
The RIM samples includes a PictureBackgroundButtonField
which implements a Bitmap button. It's what I used and has more detail than what I wrote above.