04-15-2009 08:23 PM
I've taken a look at some of the sample applications, but the default behavior appears to be for the menu to be accessed by clicking the trackball. Questions:
1. How can a menu be constructed which is accessed via the menu button.
2. How can I get rid of the "Full Menu" menu item.
3. How can I enable the "Back" and "Hangup" buttons so that they work as they do in all BlackBerry applications. (ie. The "Back" button keeps the program running and takes the user back to launcher screen, and the "Hangup" button does the same)
Thanks.
Solved! Go to Solution.
04-15-2009 09:54 PM
If you extend MainScreen, the menu key is already wired up for you. Just override makeMenu() and add your MenuItem objects to the menu.
If you extend FullScreen or other screen classes, you'll need to catch the MenuKey and call the menu yourself.
Clicking the trackball does not automatically invoke the menu - it depends on the screen context. This was also the defaul on older (4.10 and back) OS levels.
The "back" and "hangup" buttons will also work if you extend MainScreen. "hangup" (redphone) will push your app to background, "back" will generally close the current screen.
You should look at the samples in a recent version of JDE - all of this is covered.
04-15-2009 10:54 PM - edited 04-15-2009 10:54 PM
Thanks for the direction. As it turns out, the reason the default buttons weren't working is that I had overridden keyDown, keyUp, etc, and I was returning "true" from each of those functions even when I wasn't overriding the default behavior.
Thanks for the tip about overridding the makeMenu function. That worked great. Note that I did a quick grep through the samples directory and didn't see any matches for "makeMenu".
04-16-2009 12:15 AM
I just did a search on the samples and found 57 occurrences of makeMenu()
![]()
04-16-2009 11:05 PM
Am I looking in the wrong spot?
C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\samples\...
04-16-2009 11:46 PM
Hi,
Just search for menu or addMenuItem you will find code related to menu.
03-30-2010 06:14 AM
To sum up:
1) If you extends MainScreen, just override makeMenu
protected void makeMenu(Menu menu, int instance) {
super.makeMenu(menu, instance);
menu.add(new MenuItem("a",110,10) {
public void run() {
}
});
}2) If you extends FullScreen, you MUST especify style DEFAULT_MENU and then override the make Menu
3) If you don't want default menu (e.g ShowKeyboard, Switch Application, Close), then don't call super.makeMenu
4) If you want higher level control of the menu: override onMenu() . This will be called when never user click on Menu button and normally (as in documentation), onMenu() will call makeMenu().
08-19-2011 10:27 PM
How to hanlde "on click" menu, by its code..?
Many Thanks