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
Highlighted
New Developer
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified
Accepted Solution

Keys are not working in native text editor (Textbox field)

[ Edited ]

Hi all,

 

   I am porting an application for one of the blackberry device, In that for soft key mapping i am using the RIM api so that i can map LSK to Menu key and RSK to Back key. But in the application TextBox field also is there, when i open the  (Textbox) native text editor and try to input through keypad none of the keys are working.

 

Can anyone suggest some ideas to make the keys work in native text editor.

 

Note : This issue occurs only when i use RIM api. 

Message Edited by shaanganesh on 06-03-2009 07:30 AM
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Keys are not working in native text editor (Textbox field)

If you are using keyChar() to map the keys, don't forget to re-delegate the keystrokes that you are NOT consuming.

 

like this:

 

return super.keyChar()

 

 

New Developer
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified

Re: Keys are not working in native text editor (Textbox field)

hi my code looks like this

 

public boolean keyDown(int keycode,int time)    {

        mKeyCode = Keypad.key(keycode);
       
         switch(mKeyCode){
           case 4098://LSK
                   keyPressed(LEFT_SOFTKEY_KEYCODE);
               break;
           case 27://RSK
                   keyPressed(RIGHT_SOFTKEY_KEYCODE);
               break;

           case 69://key1
                   keyPressed(MyCanvas.KEY_NUM1);
               break;
           case 84://key2
                   keyPressed(MyCanvas.KEY_NUM2);
               break;

               }

           return true;

            }

 

public void keyPressed (int keyCode) {
            if(keyCode == 49){
            textBox = new TextBox("Enter Text:","",500,TextField.ANY);
            cmdLeft = new Command("OK", Command.OK, 1);
            cmdRight = new Command("Cancel", Command.CANCEL, 1);
            textBox.addCommand(cmdLeft);
            textBox.addCommand(cmdRight);
            textBox.setCommandListener(new CommandListener() {           
                public void commandAction(Command cmd, Displayable disp) {
                    if(cmd == cmdLeft) {
                        resultText = textBox.getString();
                        if(resultText.equals("") || resultText == null)
                            resultText = "Null";
                        removeCommand(cmdLeft);
                        removeCommand(cmdRight);

                    }
                    else if(cmd==cmdRight) {
                        changeDisplay(canvas);                       
                        removeCommand(cmdLeft);
                        removeCommand(cmdRight);
                        repaint();
                    }
                }
            });           
           
               changeDisplay(textBox);
            }
 }

 

so here when num key 2 is pressed, I am opening a text field but inside that none of the keys are working.

Since this is a native text editor the device itself should handle the key input in textfield area. But I have no idea why it is not taking any keys.

 

thanks,

Shaan

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Keys are not working in native text editor (Textbox field)

Your keyDown() method is "eating" all key events. You should be returning "false " for all events that are not handled.

 

 

 

New Developer
Posts: 18
Registered: ‎05-21-2009
My Device: Not Specified

Re: Keys are not working in native text editor (Textbox field)

Thanks for the solution. it is working fine now. :-)