Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » [JFACE] MenuManager context menu has wrong parent when dragging a view outside the workbench
[JFACE] MenuManager context menu has wrong parent when dragging a view outside the workbench [message #333167] Thu, 27 November 2008 05:44 Go to next message
Eclipse UserFriend
Hello,

I needed to create dynamics context menu in my RCP application. I have
3 specialized MenuManagers already filled that i can use in different views.

My problem is that i have a TreeViewer and depending on the item
selected i set the good menu.

it looks like :

// create SWT menus
Menu1 = MenuManager1.createContextMenu(TreeViewer.getControl());
Menu2 = MenuManager2.createContextMenu(a TreeViewer.getControl());
Menu3 = MenuManager3.createContextMenu(a TreeViewer.getControl());

// call setMenu() to set the good menu depending on the item selected
TreeViewer.getControl().addMenuDetectListener(new MenuDetectListener() {
public void menuDetected(MenuDetectEvent e) {
if (selectedItem == 1) {
TreeViewer.getControl().setMenu(Menu1);
} else if (selectedItem == 2)
TreeViewer.getControl().setMenu(Menu2);
} else if (selectedItem == 3) {
TreeViewer.getControl().setMenu(Menu3);
}
}
});

The problem is when i drag the view outside the workbench, I get
java.lang.IllegalArgumentException: Widget has the wrong parent

because the setMenu(Control control) method look at the parent shell of
the control and it has changed because the dragged view is in a new shell.

Does anyone can explain me if i am doing it the wrong way ?

Thanks
Laurent.
Re: [JFACE] MenuManager context menu has wrong parent when dragging a view outside the workbench [message #333177 is a reply to message #333167] Thu, 27 November 2008 14:21 Go to previous messageGo to next message
Eclipse UserFriend
Please open a bug against
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=UI

It might be that we're doing something wrong or that SWT doesn't
re-parent all child controls (menus do pass themselves up and register
against the shell, at least in GTK+)

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: [JFACE] MenuManager context menu has wrong parent when dragging a view outside the workbench [message #1847848 is a reply to message #333177] Wed, 10 November 2021 06:34 Go to previous message
Eclipse UserFriend
Is there a workaround? Because the issue is still present

[Updated on: Wed, 10 November 2021 06:34] by Moderator

Previous Topic:Change default browser
Next Topic:How can I turn off autoraise when eclipse receives focus
Goto Forum:
  


Current Time: Fri May 02 04:51:55 EDT 2025

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

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

Back to the top