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
Posts: 21
Registered: ‎06-23-2011
My Device: 9700
My Carrier: Vodafone
Accepted Solution

Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

Firstly I have searched, and have seen the solutions to setDirty(false) or to override the onSavePrompt(true) examples, however I am having some problems with intergrating this within my existing code.

 

My class is extending a different module not MainScreen (is this the problem?) and I am overriding the makeMenu item to populate my menu.

 

What I require is for the ability to hide the silly "Changes Made" prompts box shown within my menu close item. My Code at the moment is this

 

Here is a snippet of my code...

 

public final class fgw_home_screen extends TooltipScreen implements TooltipListener, TxtPackResource {
    
        
    public fgw_home_screen() {
       
        //create a menu item for users to close the application
        private MenuItem _closeItem = new MenuItem(_txt.getString(BTN_CLOSE), 200000, 10) {
                public void run()
                {
                    onClose();

                }
        }; 
        
        //override makeMenu to add the new menu items
        protected void makeMenu( Menu menu, int instance )
        {           
                menu.add(_closeItem);
        }
}

 

Developer
Posts: 95
Registered: ‎10-19-2010
My Device: Blackberry 8110
My Carrier: Generic

Re: Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

Try this in your screen class:

 

public boolean onClose() {

   return true;

}

 

private MenuItem _closeItem = new MenuItem("Close", 200000, 10) {

   public void run() {

         close();

   }

};

Contributor
Posts: 21
Registered: ‎06-23-2011
My Device: 9700
My Carrier: Vodafone

Re: Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

No change im afraid, its still prompting saying "changes made!"

Developer
Posts: 95
Registered: ‎10-19-2010
My Device: Blackberry 8110
My Carrier: Generic

Re: Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

I forgot to mention this: public boolean onSavePrompt() { return true; } If you still have problems with this post your screen class and I will test it in my computer.
Contributor
Posts: 21
Registered: ‎06-23-2011
My Device: 9700
My Carrier: Vodafone

Re: Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

[ Edited ]

Sorry that didnt work either...

 

Here is my complete code

 

no longer needed

 

Highlighted
Developer
Posts: 95
Registered: ‎10-19-2010
My Device: Blackberry 8110
My Carrier: Generic

Re: Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

private MenuItem _closeItem = new MenuItem("Close", 200000, 10) {
   public void run() {
       close();
   }
};        

public boolean onClose() {
  return super.onClose();
}
        
public boolean onSavePrompt() { return true; } 

 This works for me

Contributor
Posts: 21
Registered: ‎06-23-2011
My Device: 9700
My Carrier: Vodafone

Re: Creating a menu close item to avoid the "Changes Made" alert rubbish thing :P

Works a treat - thanks.

 

I must of been doing something different. Thanks again!