12-17-2009 04:54 AM
Is it possible to disable the back button, or ideally show a menu on click?
Solved! Go to Solution.
12-17-2009 05:09 AM
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.
12-17-2009 05:14 AM
Check this.
protected boolean keyDown(int keycode, int status)
{
if(Keypad.key(keycode) == Keypad.KEY_ESCAPE)
{
return true;
}
return false;
}
12-17-2009 05:15 AM
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.
12-17-2009 05:23 AM
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.
12-17-2009 05:24 AM
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.
12-17-2009 05:26 AM
you can instantiate your own Menu object and use the show method to display it.
12-17-2009 05:26 AM
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?
12-17-2009 05:43 AM
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.
12-17-2009 05:49 AM
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);
}