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
Developer
mabs
Posts: 129
Registered: ‎09-21-2009
My Device: Not Specified
Accepted Solution

disable back button

Is it possible to disable the back button, or ideally show a menu on click?

Please use plain text.
Developer
zany
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: disable back button

Hi,

   Yes, it is possible to disable the back button. When we are clicking the back button, it will internally call the close() of screen. if there is the screen was available in the screen stack, this method will pop out the current screen. if there was no screen in the stack then will close the application.

 

 You can override this method to disable the back button by doing nothing within it.

 

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: disable back button

Check this.

protected boolean keyDown(int keycode, int status)
{
     if(Keypad.key(keycode) == Keypad.KEY_ESCAPE)
     {
         return true;
     }
     return false;
}

 


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: disable back button

while zany is correct you can intercept the button itself, too.

use the keyChar method and check for key being Characters.ESCAPE. You can do whatever you want there, return true to stop further processing of the key.

----------------------------------------------------------
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
mabs
Posts: 129
Registered: ‎09-21-2009
My Device: Not Specified

Re: disable back button

Thank you all, how would I call the menu on the click of escape?  I would like to provide some form of navigation, this would be an ideal way of doing it.

Please use plain text.
Developer
mabs
Posts: 129
Registered: ‎09-21-2009
My Device: Not Specified

Re: disable back button

I should add, I have already created a menu which is used,

 

    protected void makeMenu(Menu menu, int instance)
    {
        menu.add(_showGraph);
        menu.add(_showSelectedGraph);
        menu.add(_hideGraph);
        menu.addSeparator();
        menu.add(_portfolioPage);
        menu.addSeparator();
        
        super.makeMenu(menu, instance);
    }

 

How would I create a second menu and add it to the click of escape.

 

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: disable back button

you can instantiate your own Menu object and use the show method to display it.

----------------------------------------------------------
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
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: disable back button

You would like to provide the menu means like to popup screen with some options or like to open teh default menu of BB device?


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
mabs
Posts: 129
Registered: ‎09-21-2009
My Device: Not Specified

Re: disable back button

I would like to use the blackberry menu, however I have created one already, so if back button clicked I would like to show a different one.

Please use plain text.
Developer
mabs
Posts: 129
Registered: ‎09-21-2009
My Device: Not Specified

Re: disable back button

Hi Simon, how would I do that? I have tried below, creating a new menu, onclick of a button show menu2.  This does not compile. (does not like me calling it in the FieldChangeListener)

 

 

private Menu menu2

...

        FieldChangeListener bhandler = new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
            {
                menu2.Show();                 
             }
        };
...

    protected void makeMenu(Menu menu2, int instance)
    {
        menu2.add(an_item);

        super.makeMenu(menu2, instance);
    }

 

 

Please use plain text.