08-27-2010 12:33 AM
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.
Solved! Go to Solution.
08-27-2010 12:38 AM
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.
08-27-2010 01:07 AM
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.)