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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 41
Registered: ‎08-11-2010
My Device: BlackBerry Simulator
My Carrier: None
Accepted Solution

onClose Back Button

Hi  friends

 

I wanted to know whether onClose() is called by default when we press back /  escape button. This is a very strange problem for me as this was not happening few days back. Although some time back I messed up my code by implementing Key Listener since I wanted to close the screen when escape is pressed. Now I have removed KeyListener from my code but its effect still remains. I have kept onClose since I want the user to go out he presses a button.

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: onClose Back Button

The framework will call onClose() in response to the escape key if the screen has the DEFAULT_CLOSE style bit set. For the escape key to work, you need to include DEFAULT_CLOSE whenever you explicitly set the style for your screen.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Contributor
Posts: 41
Registered: ‎08-11-2010
My Device: BlackBerry Simulator
My Carrier: None

Re: onClose Back Button

@Ted_Hopp: Thanks for your reply. What value should I provide so that ESC executes normally and doesnt call onClose.

 

public static final long DEFAULT_CLOSE
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: onClose Back Button

I was talking about Screen.DEFAULT_CLOSE. However, I read your initial post incorrectly. You should specify a style that does not include DEFAULT_CLOSE.

 

An alternative (and probably better) way is to override onClose(). Put your logic there about when to close the screen and when to do something else. (I think users usually expect the ESC key to work like a "back" button. You should think carefully about the wisdom of changing this.)




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Highlighted
Contributor
Posts: 41
Registered: ‎08-11-2010
My Device: BlackBerry Simulator
My Carrier: None

Re: onClose Back Button

@Ted_Hopp: onClose was being called by default. I have moved the logic to some button and onClose works normally; the way I wanted it to work.