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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Developer
Posts: 2
Registered: ‎10-30-2008
My Device: Not Specified
Accepted Solution

Context menu behaviour

Developing with version 4.2 of the JDE

I'm confused about how the system behaves with context menus:  I have a screen class that inherits from MainScreen, containing an ObjectList for which I've provided a makeContextMenu function.

I was expecting makeContextMenu to be called when the user clicks the trackball on one of the ObjectList's items, but it only seems to be invoked when the user presses the menu button.  Confusingly, overriding onMenu in the screen class shows that, when the trackball is clicked, the instance parameter is INSTANCE_CONTEXT, and when the menu button is pressed it's INSTANCE_FROM_MENU_KEY, so I would have expected makeContextMenu to be called when the ObjectList has focus.

Am I missing something, or do I need to override the screen's makeMenu to get the desired behaviour (context menu only when the track-ball is clicked, full menu when the menu button is pressed)?

BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Context menu behaviour

You can control this by overriding makeMenu.  Please see the following for more information.


How To - Distinguish between a full menu and a primary actions menu
Article Number: DB-00565



Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 2
Registered: ‎10-30-2008
My Device: Not Specified

Re: Context menu behaviour

Thanks for your help with this.

In the end, I made a base class for all of my main screens, extending from MainScreen, which defined two abstract methods: addContextMenuItems and addFullMenuItems for subclasses to define.  In its makeMenu method, I check the value of the 'instance' parameter and only call addFullMenuItems if it's Menu.INSTANCE_DEFAULT.

This has one other benefit, in that I can set a flag in the constructor according to whether DEFAULT_MENU is specified and only call super.makeMenu in makeMenu if this has been set, because in some instances I want to define my own 'close' menu item.  I always call super.makeMenu if instance == Menu.INSTANCE_CONTEXT because this adds the 'Full Menu' option.

Hopefully this is a sensible approach and will be useful to someone else!