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
New Developer
New Developer
CEC
Posts: 23
Registered: ‎04-22-2009
My Device: Not Specified

Unable to display some menu items

I'm trying to display some standard menu items on several screens and am having a lot of difficulty adding items to the full menu, which is something that I thought would be rather easyI'm using eclipse with OS version 4.5 and the 8300 simulatorThe screens are:

  1. Screen 1 has a list fieldThe standard menu items (INSTANCE_DEFAULT) and context menu items (INSTANCE_CONTEXT) work as expected.
  2. Screen 2 has 2 date fields, 2 choice fields and 4 buttonsThe standard and context menus work as expected
  3. Screen 3 has 2 date fields, 2 radio groups, a label and 2 buttonsIt appears that the menu items displayed by pressing the menu key are from the default (INSTANCE_CONTEXT_SELECTION).  I tried adding my standard menus to this instance, but they are still ignoredIt also ignores my (INSTANCE_CONTEXT) menu items.
  4. Screen 4 has 1 RichTextField and 7 buttonsThis screen will display my (INSTANCE_CONTEXT) menus and the system context menus, but ignores both my (INSTANCE_DEFAULT) and (INSTANCE_CONTEXT_SELECTION) menu items.

The menus are used for navigation among the screens and implemented by adding the following code to each class

 

protected void makeMenu(Menu menu, int instance) { super.makeMenu(menu, instance); // For screen specific menus if (instance == Menu.INSTANCE_CONTEXT){ menu.add(view); menu.add(email); menu.add(save); } else if (instance == Menu.INSTANCE_CONTEXT_SELECTION){ // for field specific menus menu.add(view); menu.add(email); menu.add(save); menu.addSeparator(); menu.add(screen1); menu.add(screen2); //menu.add(screen3); menu.add(screen4); menu.add(help); } else if (instance == Menu.INSTANCE_DEFAULT){ menu.add(view); menu.add(email); menu.add(save); menu.addSeparator(); menu.add(screen1); menu.add(screen2); //menu.add(screen3); menu.add(screen4); menu.add(help); } }

 The separators don't show up on any of the screens, but that is a minor inconvenience right nowI vaguely remember reading something about you only need to implement the default menu items onceI haven't been able to find that comment again and am not sure if that applied at the application level or the screen levelIt looks like it successfully calls the super.makeMenu when it creates each screenI would appreciate any guidance on implementing standard menus across multiple screens.

 

Thanks 

 

 

 

Please use plain text.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: Unable to display some menu items

Please use plain text.
New Developer
New Developer
CEC
Posts: 23
Registered: ‎04-22-2009
My Device: Not Specified

Re: Unable to display some menu items

Thanks for referring me to the link.  I previously visited that site while searching for help and thought it may help me with the addseparator problem I'm having.  While taking a look at it again I noticed the section on the addMenuItem() method of the mainscreen.  I ignored this the first time around as that wasn't the way I was trying to add the menus and all of the samples showed the method I posted above.  Should I be using the addMenuItem() method instead?

 

I'll give it a try, but it seems odd to have to go this route for some items. 

Please use plain text.
Developer
johnbibs
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: Unable to display some menu items

did you try modifying the ordinal of your menuItem? 
Please use plain text.
New Developer
New Developer
CEC
Posts: 23
Registered: ‎04-22-2009
My Device: Not Specified

Re: Unable to display some menu items

[ Edited ]

Yes, I changed the context menu items to 8,000 and the standard menu items to 310,000 on screen 1 and it didn't seem to have any affect. However, I was only working on the separator at that point in time so didn't try it on the others. I'll try it on the other screens.

 

 

Finished changing the other screens and it did not have any effect.

Message Edited by CEC on 07-26-2009 10:34 PM
Please use plain text.
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Unable to display some menu items

Hi,

 

Try adding menu on each screen instead of this centralize scheme , define makeMenu() on each screen and add specific menu items in that code.

 

May be what is happening is all your menu items are getting added whenever the condition is satisfied as you are not removing previous menu items.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.
New Developer
New Developer
CEC
Posts: 23
Registered: ‎04-22-2009
My Device: Not Specified

Re: Unable to display some menu items

Rajat,

 

Perhaps I wasn't clear above.  I am adding the makeMenu and Menu Item methods to each screen.  I was actually wondering if the problem was because I was adding the default menu multiple times, once for each screen.  When I step through the program with break points, super.makeMenu will be called then it will check the instance values.  The instance value it is checking for is "0", which I believe is the value for default.  However, it seems to just skip right over it.

 

I went back and tried addMenuItem() to see if that would work.  You can't override makeMenu and use addMenuItem() so I commented out that section.  It still ignored my menu.

Please use plain text.
New Contributor
andrespch
Posts: 5
Registered: ‎03-20-2011
My Device: 9800
My Carrier: idk

Re: Unable to display some menu items

hey sorry can you guys plz help me? I've tried like 5 menu Item sample codes so far and somehow I never get to see the menu, I'm not getting any errors or anything what makes it more difficult to find out what's gonna happen, I also tried the code from the sample without success, am I missing some procedure  one has to do before testing the menu? IÄm using the 9800 simulator by the way

Please use plain text.