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
Contributor
joleary
Posts: 14
Registered: ‎06-22-2011
My Device: 9700

9700 and clickable bitmapfields

Have been using the below code for creating a clickable BitmapField on the 9800 simulator  and it was working fine  fine.

 

When I take this exact same code and put it in a "Hello World" program on the 9700 simulator I can see the BitmapField  but I cant click on it.

 

Now I notice using the 9700 simulator that i cant use the mouse for clicking on buttons/fields on the screen. Is there something Im missing to make the button clickable on the 9700 simulator or does the 9700 not provide support for clickable BitmapField? 

 

 

 

Bitmap login = Bitmap.getBitmapResource("test.png");BitmapField loginButton = new BitmapField(login, BitmapField.FOCUSABLE) {
   protected boolean navigationClick(int status, int time) {Dialog.alert("Login Image Clicked.");
return true;    }};

Please use plain text.
Contributor
joleary
Posts: 14
Registered: ‎06-22-2011
My Device: 9700

Re: 9700 and clickable bitmapfields

I got this working by doing the below, basically I override the keyChar() so I can intercept the key being pressed and added a listener to the bitmapfield for this. 

 

I'm wondering is there a better way for doing this as it seems quite clunky? Still unsure why I need to do this on the 9700 and not on the 9800, possibly  something to do with the way the 9800 supprorts click events generated by the mouse in the simulator?

 

 

BitmapField loginButton = new BitmapField(login, BitmapField.FOCUSABLE) {
 

 protected boolean keyChar(char key, int status, int time) {if (key == Keypad.KEY_ENTER) {    fieldChangeNotify(FieldChangeListener.PROGRAMMATIC);    return true;}return super.keyChar(key, status, time);    }};


loginButton.setChangeListener(new FieldChangeListener() {    public void fieldChanged(Field field, int context) {Dialog.alert("Login Clicked");    }});

Please use plain text.
Contributor
joleary
Posts: 14
Registered: ‎06-22-2011
My Device: 9700

Re: 9700 and clickable bitmapfields

I'd like to get a way this can work on both the 9700 and 9800
Please use plain text.
New Developer
Farid123
Posts: 160
Registered: ‎03-02-2011
My Device: Not Specified

Re: 9700 and clickable bitmapfields

BitmapField loginButton = new BitmapField(login, BitmapField.FOCUSABLE) {
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
};
loginButton.setChangeListener(this);
Dialog.alert("Clicked");

Try this!!
Please use plain text.