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: 100
Registered: ‎01-08-2009
My Device: Not Specified

Issues in handling Back and delete key on the same screen

Hello experts. Please have a look at my problem : 

I am unable to handle the Delete key and Back key on the same screen.

 

when I use this code, I am able to successfully navigate to the previous screen in the stack.

 

protected boolean keyChar(char arg0, int arg1, int arg2) {
        if(arg0==Characters.ESCAPE)
        {  
            switchTo(Constants.TYPE_MAIN_SCREEN);           
            return true;
        }       
        else
            return false;

    }

 

However This prohibits me from deleting a character from the textbox on this screen.

So I thought either of these two would work but they dint!

 

if(arg0==Characters.ESCAPE)
        {  
            switchTo(Constants.TYPE_MAIN_SCREEN);                 
        }              
        return true;

    }

 

OR

 

protected boolean keyChar(char arg0, int arg1, int arg2) {
        // TODO Auto-generated method stub
        if(arg0==Characters.ESCAPE)
        {   
            cnsScreenObject = new CnsScreen(
                    sendP);
            cnsScreenObject
                    .buildScreen(Constants.TYPE_MAIN_SCREEN);            
            return true;
        }
        else if(arg0==Characters.BACKSPACE)
        {
            return true;
        }
        else
            return false;//super.keyChar(arg0, arg1, arg2);
    }
   
So kindly suggest me ways so that I could navigate to the previous screen as well as I could delete characters inside a textbox component on the same screen.

What set of characters shall I use?

 

Thanks

 

Regards
Akash Saxena
Blackberry Developer,
Wirkle.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Issues in handling Back and delete key on the same screen

The backspace and escape keys are for the keyboard/keypad. I think the keys you are looking for are the Keypad key constants for the HW keys. I think they are KEY_END and KEY_ESCAPE, but I'm not sure which.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Issues in handling Back and delete key on the same screen

Does this work for you?

 

protected boolean keyChar(char arg0, int arg1, int arg2) {
        if(arg0==Characters.ESCAPE)
        {  
            switchTo(Constants.TYPE_MAIN_SCREEN);           
            return true;
        }       
        else
            return super.keyChar(arg0, arg1, arg2);

    }

Developer
Posts: 100
Registered: ‎01-08-2009
My Device: Not Specified

Re: Issues in handling Back and delete key on the same screen

Thanks Mr Strange,

That worked!!

Regards
Akash Saxena
Blackberry Developer,
Wirkle.