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
Regular Contributor
salmankhan7788
Posts: 52
Registered: ‎02-26-2013
My Device: Curve 9650,Bold 9900

how to overwrite escape key (Key_Escape)...?

Hello

  In my application i need to overwrite some key like end key and escape key. end key overwriting works properly but escape key not.

i use code to overwrite these keys like this ,  i already implements keylistener interface

 

 int key = Keypad.key( keycode );

 if(  key == Keypad.KEY_END )
        {
            
            UiApplication.getUiApplication().requestBackground();

            
        }
        else if(  key == Characters.ESCAPE)
        {
            
            UiApplication.getUiApplication().requestBackground();

            
        }

other approach i used for escape key is

 

 if(  key == Keypad.ESCAPE)
        {
            
            UiApplication.getUiApplication().requestBackground();

            
        }

 

plz give me a suitable help for this problm..

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: how to overwrite escape key (Key_Escape)...?

overwrite the keyChar method in mainscreen.
return true after you have handled an input, otherwise return super.
----------------------------------------------------------
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
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to overwrite escape key (Key_Escape)...?

for example:

 

        protected boolean keyChar(char character, int status, int time) {
                // regardless of where we are, Esc will exit
                switch (character) {
                        case Characters.ESCAPE:
                                close();
                                return true;
                        default:
                                return super.keyChar(character, status, time);
                }
        }