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
anurosh
Posts: 8
Registered: ‎10-30-2008
My Device: Not Specified
Accepted Solution

How to remove menu item inserted by BrowserContent

I have an application where a browser field gotten from browserContent.getDisplayableContent() is added to the main screen. This adds "Select Mode", "Page View" and "Find" menus. How do I get rid of these. I overrode protected void makeMenu(Menu menu, int instance) but the menu items do not go away.

 

 

protected void makeMenu(Menu menu, int instance) { Field focus = UiApplication.getUiApplication().getActiveScreen().getLeafFieldWithFocus(); if(focus != null) { ContextMenu contextMenu = focus.getContextMenu(); contextMenu.clear(); this.getContextMenu().clear(); } }

 


 

My application is basically similar to the BrowserFieldSampleApplication.java sample that is part of the SDK.

Thanks for your help

Please use plain text.
Administrator
MSohm
Posts: 14,241
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: How to remove menu item inserted by BrowserContent

You can call super.makeMenu to have the menu be recreated without the items from the field.
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
Please use plain text.
New Developer
anurosh
Posts: 8
Registered: ‎10-30-2008
My Device: Not Specified

Re: How to remove menu item inserted by BrowserContent

In the BrowserFieldDemo sample application that is part of the SDK, I created MyMainScreen which extends MainScreen, and overrode makeMenu:

 

class MyMainScreen extends MainScreen {
public MyMainScreen() { }

protected void makeMenu(Menu menu, int instance)
{
super.makeMenu(menu, instance);
}
}

In BrowserFieldDem.java, I then create the main screen using the above class:

_mainScreen = new MyMainScreen();

 

However, the menu items inserted by Field field = browserContent.getDisplayableContent() still gets displayed.

In other application where I do not use the browser controls and just use "regular" widgets like buttons, labels, and text fields, I have been able to customize my menu.

 

However, when I use the Browser field, even thpugh I can "add" my own menu items, I have not been able to get rid of the menu items inserted by the browser field, such as "Find", "Page mode", etc.

 

Thanks

Please use plain text.
New Developer
anurosh
Posts: 8
Registered: ‎10-30-2008
My Device: Not Specified

Re: How to remove menu item inserted by BrowserContent

I managed to solve it this way. In my class that extends MainScreen, I overrode makeMenu():

 

protected void makeMenu(Menu menu, int instance)
{
menu.deleteAll();
menu.add(myMenuItem1);
menu.add(myMenuItem2);
super.makeMenu(menu, instance);
}

 

The deleteAll()  method deletes ALL menu items - then I add my own menu items. Finally, calling super.makeMenu() adds the "Close" menu item.

 

 

Please use plain text.