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
Highlighted
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,727
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

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
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!