I made a custom ButtonField class where I have an image as a button. However, I would like to be able to select this image and to know it is selected, either by partially highlighting it or putting a square around it, whatever. I have a BitmapField in my UI that highlights itself in blue when I select it, but my other images that use ImageButtonField, do not have the blue highlight. I do not want the bitmap to disappear completely when selected.
here is the code :
package mypackage;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.component.BitmapField;
public class ImageButtonField extends BitmapField{
public ImageButtonField(Bitmap image) {
super(image);
}
public boolean isFocusable() {
return true;
}
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
protected boolean trackwheelClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
protected boolean keyChar(char character, int status, int time) {
if(Characters.ENTER == character || Characters.SPACE == character) {
fieldChangeNotify(0);
return true;
}
return super.keyChar(character, status, time);
}
}
Any help modifying this class so it works would help immensely. I have had no success trying to make this work!
To remove default styling attributes you can add following methods:
You can override paint method and do paint whatever you want by checking focus status, e.g. following code will paint a red transparent layer over the bitmap image.
Actually I didn't understand your question well :).