I created a J2ME Application for Blackberry phone and initially, I have this piece of code which is to detect when user presses the ESC button.
//When application closes
public boolean onClose() {
System.exit(0);
return true;
}
//When user press ESC key OnClose() would be called
public boolean keyChar(char key, int status, int time) {
if(key == Characters.ESCAPE){
onClose();
}
return true;
}
However, when doing this, I faced a problem of allowing the user to input anything into the EditField!!
So I just had to add this piece of line in the keyChar method to make it work :)
return super.keyChar(key, status, time);
You keyChar method should now look like this:
//When user press ESC key OnClose() would be called
public boolean keyChar(char key, int status, int time) {
if(key == Characters.ESCAPE){
onClose();
}
return super.keyChar(key, status, time);
}
Problem solved! :D
Monday, 24 November 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment