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


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.


Reply
Developer
Posts: 28
Registered: ‎07-16-2008
My Device: Curve 8320
Accepted Solution

HOWTO Remove CLOSE from Field ContextMenu

I'm overriding makeContextMenu(ContextMenu contextMenu) in an attempt to create my own context menu.  Everything works ok as I am able to contextMenu.addItem(_newMenuItem1) to add my menu items.  I have been unsucessful in removing the CLOSE menu option however.  Any ideas?  Thanks
BlackBerry Development Advisor
Posts: 15,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: HOWTO Remove CLOSE from Field ContextMenu

Please see this link.

 

How To - Remove the default "Close" or "Hide" MenuItems from a Screen 
Article Number: DB-00506

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

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 28
Registered: ‎07-16-2008
My Device: Curve 8320

Re: HOWTO Remove CLOSE from Field ContextMenu

Thanks for the reply.  I did see that article.  It says that if I don't call super.makeMenu(menu, instance); I won't get

the CLOSE menu option.  However with ContextMenu I'm not calling super.makeContextMenu(ContextMenu contextMenu)

but I'm still getting the CLOSE.  Could it work differently for ContextMenu??

 

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

Re: HOWTO Remove CLOSE from Field ContextMenu

Overriding makeContextMenu allows you to customize the context sensitive menu items that are created from a Field (i.e. Copy, Paste, Select, Change Option) and vary based on the type of field and cursor location.

 

Overriding makeMenu gives you full control over the menu.  This is what constructs the entire menu for the screen, which is where the Close menu item is populated from.

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: ‎11-06-2009
My Device: Not Specified

Re: HOWTO Remove CLOSE from Field ContextMenu

Sorry for posting to a thread with a solution - but I have tried this solution and it's not working. I am wondering if it

is specific to a version of the JDE?

 

 

New Developer
Posts: 7
Registered: ‎11-12-2009
My Device: Not Specified

Re: HOWTO Remove CLOSE from Field ContextMenu

Here's how I did it ( It's working properly ).

 

First: create a java.util.Vector, to store all of your menu items at the top of your class.

 

class MeScreeny extends MainScreen {

    Vector _menuItems = new Vector();

...

 

Second: override the addMenuItem method, to keep track of all of the menu items that you want to add.

 

public void addMenuItem ( MenuItem item ) {

 _menuItems.addElement ( item );

}

 

Third: override the makeMenu method, to add just the items that you want.

 

protected void makeMenu( Menu menu, int instance ) {
    for ( int i = 0; i < _menuItems.size(); i++ ) {
        menu.add( (MenuItem) _menuItems.elementAt( i ));
    }
}

 

Fourth: create your menu items as you normally would:

 

MenuItem myitem = new MenuItem( "My_Menu_Item", 1, 254 ) {
    public void run() {

...

    }
};

addMenuItem( myitem );

 

That should do it for you.  Only your items will appear.

Make sure that on your implementation of the makeMenu method, you don't call super.makeMenu(.......).