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
New Developer
senthilkumar05
Posts: 6
Registered: ‎08-18-2008
My Device: Not Specified
Accepted Solution

Handling Numeric keypress and keyrepeat in Blackberry

For BB curve and Blackberry 8820, i need to handle the numeric key pad directly (without pressing the alt).

since my requirement doesn't require any user input. It simply performs the action based on the numeric key the user selects. and also up/down/left/right keys.

 

J2ME keypressed method is like this

protected void keyPressed(int keyCode)  {

switch (getGameAction(keyCode))
                {
                   case LEFT: doSomething();break;

                   case UP: doSomething();break;
                   case RIGHT: doSomething();break;
                   case DOWN:doSomething();break;
                   case FIRE: doSomething();break;

     } 

Please advice me how to handle the above snippet of j2me code in Blackberry,

public boolean keyDown(int keycode, int time) {

 /// ?

 

In the KeyRepeated i want to handle the numeric key's if user is pressing for some long time

and j2me key repeated()  is like this:

protected void keyRepeated(int keyCode){


  if ((keyCode >= KEY_NUM1) && (keyCode <= KEY_NUM9))
 {

       doSomething();

  } 

}

 

please help me in writing the above code in  Blackberry  

 public boolean keyRepeat(int keycode, int time) {

//??    ..

// I have tried like this, But haven't got the expected result. 

 if ((keycode >= Characters.DIGIT_ONE) && (keycode <= Characters.DIGIT_NINE))
      {

        ...... 

   }

 

Do we need to use navigationClick(..) to acheive this, if so pls suggest me

 

Thanks

Senthil

 

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Handling Numeric keypress and keyrepeat in Blackberry

Are you creating a MIDlet or BlackBerry CLDC application?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
senthilkumar05
Posts: 6
Registered: ‎08-18-2008
My Device: Not Specified

Re: Handling Numeric keypress and keyrepeat in Blackberry

I have a MIDlet application, presently im  porting into Blackberry CLDC application.

so i need a know how to handle the keypress and keyrelease using Blackberry  API

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Handling Numeric keypress and keyrepeat in Blackberry

You can override the keyDown and keyUp methods in the Screen and Field classes to capture key input and know when a user presses and releases a key.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
senthilkumar05
Posts: 6
Registered: ‎08-18-2008
My Device: Not Specified

Re: Handling Numeric keypress and keyrepeat in Blackberry

Yes, I did that,  But the problem is how to handle the  up,down, left,right key movements, Since we have a trackball in blackberry, how to handle that. Here is the scenario, there is 3x3 cells, each cell is selectable item,Initally control will be highlighted on first cell. when the user moves the trackball left,we should detect that and move the selectable item to left, like wise, based up on the user movements we need to handle the up,down,left,right and fire key events.

 

(1) J2ME keypressed method is like this

protected void keyPressed(int keyCode)  {

switch (getGameAction(keyCode))
                {
                   case LEFT: doSomething();break;

                   case UP: doSomething();break;
                   case RIGHT: doSomething();break;
                   case DOWN:doSomething();break;
                   case FIRE: doSomething();break;

     } 

Please advice me how to handle the above snippet of j2me code using  Blackberry API for Blackberry CLDC application,

 

public boolean keyDown(int keycode, int time) {

 /// how to handle

and also using trackball how to  handle up/down/left/right/fire movements , please advice me.

 

(2)

In the KeyRepeated i want to handle the numeric key's if user is pressing for some long time

and j2me key repeated()  is like this:

 

protected void keyRepeated(int keyCode){
  if ((keyCode >= KEY_NUM1) && (keyCode <= KEY_NUM9))
 {

       doSomething();

  } 

}

 

Using Blackberry API keyRepeat,

please help me in writing the above code in  Blackberry  

 public boolean keyRepeat(int keycode, int time) {

//How to handle the Numeric keys in key repeat??  

 

}

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Handling Numeric keypress and keyrepeat in Blackberry

Trackball events are passed into the navigationMovement method of the Screen and Field classes.  This method provides you with the X and Y movement of a user scrolling the trackball.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker