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
Contributor
Posts: 41
Registered: ‎11-15-2012
My Device: Curve 9320
Accepted Solution

How to get event "button back"

Hello,

 

How to create one event for where to pressed button back?

 

I some test the examples but never running!

 

cumps

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to get event "button back"

I am not sure what you mean by button back.

 

If you want to know when a Button is pressed, then you are best coding a FieldChangedListener for the Button. 

 

Let us know if this is not enough information for you.

Contributor
Posts: 41
Registered: ‎11-15-2012
My Device: Curve 9320

Re: How to get event "button back"

Button back is the button with the back arrow.

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to get event "button back"

If you are using the MainScreen, then you can override keyChar, and look for the ESCAPE character.  here is some sample code:

 

        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);
            }
        }

 

Contributor
Posts: 41
Registered: ‎11-15-2012
My Device: Curve 9320

Re: How to get event "button back"

Yes, this is it!

 

Thanks