Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Setting context menu on editable CCombo
Setting context menu on editable CCombo [message #465589] Thu, 15 December 2005 16:10 Go to next message
Allon Moritz is currently offline Allon MoritzFriend
Messages: 6
Registered: July 2009
Junior Member
How can I add a context menu to an editable CCombo??
The following standard way doesn't work:

CCombo combo = .....; //Creating the editable combo

MenuManager menuManager = new MenuManager("#PopUpMenu");
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
manager.add(new SearchAction(combo, group, parent.getShell())); // the
self written action
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS +
"-end"));
}
});
Menu menu = menuManager.createContextMenu(combo);
combo.setMenu(menu);

The problem is that the menu from the underlying text field of the combo
will be shown instead the menu set on the combo.
Re: Setting context menu on editable CCombo [message #465600 is a reply to message #465589] Thu, 15 December 2005 18:37 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
This is a bug in CCombo. Please enter a bug report against Platform SWT.

The bug is that when you call CCombo.setMenu(), the menu is being set on the
Composite that encapsulates the Text and Button. However, this composite is
completely obscured by its children so the menu can never be shown.

The fix is to override CCombo.setMenu() and set the menu on the Text widget
inside. There is no way for the application to work around this
unfortunately.

"Allon Moritz" <moa@avaloq.com> wrote in message
news:520c90c8435bcc0c054e34704bfd5686$1@www.eclipse.org...
> How can I add a context menu to an editable CCombo??
> The following standard way doesn't work:
>
> CCombo combo = .....; //Creating the editable combo
>
> MenuManager menuManager = new MenuManager("#PopUpMenu");
> menuManager.setRemoveAllWhenShown(true);
> menuManager.addMenuListener(new IMenuListener() {
> public void menuAboutToShow(IMenuManager manager) {
> manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
> manager.add(new SearchAction(combo, group, parent.getShell())); // the
> self written action
> manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS +
> "-end"));
> }
> });
> Menu menu = menuManager.createContextMenu(combo);
> combo.setMenu(menu);
>
> The problem is that the menu from the underlying text field of the combo
> will be shown instead the menu set on the combo.
>
Re: Setting context menu on editable CCombo [message #465657 is a reply to message #465600] Fri, 16 December 2005 10:43 Go to previous message
Allon Moritz is currently offline Allon MoritzFriend
Messages: 6
Registered: July 2009
Junior Member
Bug reported under https://bugs.eclipse.org/bugs/show_bug.cgi?id=121190.
Previous Topic:FormLayout
Next Topic:Modifying KTable
Goto Forum:
  


Current Time: Fri Dec 06 17:58:47 GMT 2024

Powered by FUDForum. Page generated in 0.07237 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top