Skip to main content



      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 11:10 Go to next message
Eclipse UserFriend
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 13:37 Go to previous messageGo to next message
Eclipse UserFriend
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 05:43 Go to previous message
Eclipse UserFriend
Bug reported under https://bugs.eclipse.org/bugs/show_bug.cgi?id=121190.
Previous Topic:FormLayout
Next Topic:Modifying KTable
Goto Forum:
  


Current Time: Sun Aug 31 08:50:52 EDT 2025

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

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

Back to the top