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
chackett
Posts: 29
Registered: ‎12-16-2011
My Device: Bold 9900
Accepted Solution

Popup menu when I click a button.

Hi There,

 

I have a class that extends MainScreen and I have overwritten MakeMenu() as I want to create a custom item in the menu when I press "menu".

 

My problem is that when I click a button on the screen my program does whatever it needs then after all that it displays a popup menu with the options {Switch Application | My menu | Full Menu}

 

Here is my override of makeMenu(). Note: If I remove my menu.add call is solves the problem. But obviously I need the item in the full menu and not popup.

 

Thanks in advance :smileyhappy:

 

public void makeMenu(Menu menu, int instance) {
	super.makeMenu(menu, instance);
	menu.add(new MenuItem(new StringProvider("Settings"), 110, 10) {
		public void run() {
			SettingsHome setScr = new SettingsHome();
			UiApplication.getUiApplication().pushScreen(setScr);
		}
	});
}

 

-----------------------------------------------------------------

My Blackberry Blog - Coming Soon
ConorHackett.com - My Personal Site
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Popup menu when I click a button.

The instance parameter will give you the information if it is a full menu or a context menu.

 

Check out this link:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/component/Menu.html#INSTANC...

 

E.

Developer
chackett
Posts: 29
Registered: ‎12-16-2011
My Device: Bold 9900

Re: Popup menu when I click a button.

Hi, I should have mentioned that I read that page.. but where do I set those fields? :-/
-----------------------------------------------------------------

My Blackberry Blog - Coming Soon
ConorHackett.com - My Personal Site
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Popup menu when I click a button.

[ Edited ]

You don't have to set these fields.

 

The OS takes care of it:

 

public void makeMenu(Menu menu, int instance) {
	super.makeMenu(menu, instance);
if(instance == Menu.INSTANCE_DEFAULT)
{
 menu.add(new MenuItem(new StringProvider("Settings"), 110, 10) { public void run() { SettingsHome setScr = new SettingsHome(); UiApplication.getUiApplication().pushScreen(setScr); } }); }
}

 

E.

 

 

Developer
chackett
Posts: 29
Registered: ‎12-16-2011
My Device: Bold 9900

Re: Popup menu when I click a button.

Yea I just figured it out after you pointed me at it.. I glossed over it the first time.

Thanks :smileyhappy:
-----------------------------------------------------------------

My Blackberry Blog - Coming Soon
ConorHackett.com - My Personal Site