[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform] JFace, MenuManager, submenu in a popup-menu
|
- From: martin.j.steer@xxxxxxxxx (Martin J. Steer)
- Date: Wed, 11 Oct 2006 12:41:17 +0000 (UTC)
- Newsgroups: eclipse.platform
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
I've Googled for this and scoured the web, but either I'm using the wrong
search terms or perhaps it's just something that makes me unable to
comprehend this.
I'm trying to add a submenu to a popup menu in a TableViewer. The
popup-menu works fine, but the submenu never shows. This is the code:
// Sub menu
final MenuManager subMenu = new MenuManager("Branch");
subMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(firstSubAction);
manager.add(secondSubAction);
manager.add(new
Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});
// Main Popup menu
final MenuManager popupMenu = new MenuManager("#PopupMenu");
popupMenu.setRemoveAllWhenShown(true);
popupMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(firstAction);
manager.add(secondAction);
manager.add(thirdAction);
manager.add(subMenu);
manager.add(new
Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});
final Menu menu = popupMenu.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(popupMenu, viewer);
I thought this would result in a popup menu with first-, second- and
thirdAction and then "Branch" with a submenu containing firstSub- and
secondSubAction.
Any help is greatly appreciated.
kind regards,
martin