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
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm
Accepted Solution

How can a bitmap button recognize key stroke?

Hi,

I have created an image button and it recognizes mouse click in touch Simulotor. But, when the focus is on the button, when i press ENTER, it doesn't recognize. I have to create the button for non touch handsets. Is there any solution? My code is like this

 

Bitmap bitmap1 = Bitmap.getBitmapResource("Add.png");
btField1 = new BitmapField(bitmap1, BitmapField.FOCUSABLE | DrawStyle.HCENTER)
{
  protected boolean navigationClick(int status, int click)
  {
      fieldChangeNotify(1);
      return true;
  }
};

 

Any help will be highly appreciated

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How can a bitmap button recognize key stroke?

overwrite keychar to process the keys you want to handle

----------------------------------------------------------
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
Developer
Posts: 61
Registered: ‎06-01-2009
My Device: Not Specified

Re: How can a bitmap button recognize key stroke?

I have meet this question before, but I am not using bitmapField to carry the handle functions.

( I put them in the MainScreen, using a variable "status" to record the user status ).

So I dont know if it can be done in your bitmapField. 

 

Owing the blackberry use its wheel ball's push to push "enter", so I add this function handle the wheel ball's pushing: 

 

protected boolean trackwheelClick(int status, int time) {

    // code for push enter

   return true;

}

 

And I think someone maybe push "Enter" (at least I push enter in simulator), so I add this function to handle "enter" button:

 

 

protected boolean keyChar(char c, int status, int time)    
    {

 

protected boolean keyChar(char c, int status, int time){

if ( c==Characters.ENTER ){

           //code for push enter

       }

       return super.keyChar(c,status,time);

}

 

Maybe you can try it in your bitmapField. Good Luck for you!