Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:44 Go to next message
Laurent Marchal is currently offline Laurent MarchalFriend
Messages: 91
Registered: July 2009
Member
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 19:21 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 11:34 Go to previous message
Stanislav Tartakowski is currently offline Stanislav TartakowskiFriend
Messages: 5
Registered: October 2015
Junior Member
Is there a workaround? Because the issue is still present

[Updated on: Wed, 10 November 2021 11:34]

Report message to a moderator

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


Current Time: Fri Apr 19 00:21:11 GMT 2024

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

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

Back to the top