1

when i am pressing the back button a pop screen is displayed which shows three button save, discard and cancel button i don't want this screen to be popped up. is this possible.

Thanks in advance

rupesh
  • 420
  • 2
  • 19
  • 3
    http://stackoverflow.com/questions/2461403/blackberry-disable-save-option-in-basiceditfield/2461453#2461453 – Vivart May 10 '10 at 10:26

4 Answers4

2

Override the onSavePrompt method. Then that screen will not come. Actually that popup screen will come only when something is changed on your screen. So it will ask you for the appropriate action.

    protected boolean onSavePrompt() {

    return true;

    }
Amy
  • 4,034
  • 1
  • 20
  • 34
Nsr
  • 219
  • 1
  • 11
2

The default behaviour of the back button is to save changes for dirty screens. Rewrite the onClose() method to overwrite the default behaviour.

    public boolean onClose() {
        int choice = Dialog.ask(Dialog.D_YES_NO, "¿Do you want to exit?", Dialog.YES);

        if (choice == Dialog.YES) {
             //write a close() routine to exit
            close();
        }   
        return true;
    }

You return true because you managed the ESC button pressed event. Review the Screen class docs.

You can also change the default behaviour of the ESC button rewriting the keyChar method as follows:

    protected boolean keyChar(char character, int status, int time) {
        if (character == Keypad.KEY_ESCAPE) {
            onClose();
            return true;
        }
        return super.keyChar(character, status, time);
    }

close() should be somenthing like:

public void close() {
    System.exit(0);
}
timoto
  • 105
  • 4
1

Override onClose() method like this:

public boolean onClose() {
    close();
    return true;
}

you will not get that annoying alert message.

Kai
  • 38,985
  • 14
  • 88
  • 103
1

Skip the saving prompt with it

protected boolean onSavePrompt() {
    return false;
}
Kai
  • 38,985
  • 14
  • 88
  • 103
Alex
  • 11
  • 1