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
sonanaren
Posts: 41
Registered: ‎05-26-2011
My Carrier: Developer
Accepted Solution

Diable onSavePrompt() (Save Discard Cancel)

public Screen dummyScreen() { Screen _screen = new MainScreen(NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR); _screen.add(new LabelField("TEST")); return _screen; }

 

i am creating screen like above and have a buttonField (Which his not in the above mentioned code). The above sample code to show that i am forming a screen from a method

 

my requirement is to prevent the onSavePrompt() dialog when i click escape button. i dont want the prompt to pop up

 

Any thoughts would be highly appreciated 

Please use plain text.
New Contributor
su38
Posts: 6
Registered: ‎09-20-2011
My Carrier: -

Re: Diable onSavePrompt() (Save Discard Cancel)

Just override the onSavePrompt() method. If you want it to cancel, then return false. Simply:

public boolean onSavePrompt (){
return false;
}
Please use plain text.
Contributor
sonanaren
Posts: 41
Registered: ‎05-26-2011
My Carrier: Developer

Re: Diable onSavePrompt() (Save Discard Cancel)

I am creating the screen in a method (Function), any help

Please use plain text.
New Contributor
su38
Posts: 6
Registered: ‎09-20-2011
My Carrier: -

Re: Diable onSavePrompt() (Save Discard Cancel)

public Screen dummyScreen() { 
    Screen _screen = new MainScreen(NO_VERTICAL_SCROLL |  NO_VERTICAL_SCROLLBAR); _screen.add(new LabelField("TEST")){
public boolean onSavePrompt (){
return false;
}
}; 

return _screen; 

}

 Use Java's supports for in-line class creation (I think thats what it is called).

Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Diable onSavePrompt() (Save Discard Cancel)

overwrite it anonymously
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Carrier: various

Re: Diable onSavePrompt() (Save Discard Cancel)


su38 wrote:
public Screen dummyScreen() { 
    Screen _screen = new MainScreen(NO_VERTICAL_SCROLL |  NO_VERTICAL_SCROLLBAR); _screen.add(new LabelField("TEST")){
public boolean onSavePrompt (){
return false;
}
}; 

return _screen; 

}

Almost correct - should probably be more like this:

public Screen dummyScreen() { 
  Screen _screen = new MainScreen(NO_VERTICAL_SCROLL |  NO_VERTICAL_SCROLLBAR) {
    public boolean onSavePrompt (){
      return false;
    }
  };
  _screen.add(new LabelField("TEST")); 

  return _screen; 

}

 However, if there are no EditFields there but only the above LabelField and some ButtonField(s), create your ButtonField with NEVER_DIRTY style flag instead and your problem will be solved even without overriding onSavePrompt.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Diable onSavePrompt() (Save Discard Cancel)


arkadyz wrote:
create your ButtonField with NEVER_DIRTY style flag instead and your problem will be solved even without overriding onSavePrompt.

I wish i had this style flag at home

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
su38
Posts: 6
Registered: ‎09-20-2011
My Carrier: -

Re: Diable onSavePrompt() (Save Discard Cancel)

Whoops, replied too quickly and didnt notice the labelfield...or the semi-colon.

Please use plain text.
Contributor
sonanaren
Posts: 41
Registered: ‎05-26-2011
My Carrier: Developer

Re: Diable onSavePrompt() (Save Discard Cancel)

Thanks guys, your solution worked for me

Please use plain text.