| Summary: | Context Menu doesn't show on Linux with menu.setVisible( true ) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | kevin miles <kj_miles> | ||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||
| Status: | RESOLVED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | ericwill, gheorghe, gordon.hirsch, semenia | ||||
| Version: | 3.3 | Keywords: | triaged | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux-GTK | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
kevin miles
Will check... This works for me using the latest 3.4 RC2 build. Please reopen with a snippet of code if you are still having problems. Thanks! Created attachment 103144 [details]
TestCase RCP and View named 'NICE' with embedded Swing Table
(In reply to comment #2) > This works for me using the latest 3.4 RC2 build. Please reopen with a snippet > of code if you are still having problems. Thanks! > I'm not using Eclipse 3.4... we're using 3.3.0 I am adding a simple rcp plugin and another plugin that contributes a view that has a swing table embedded. This all works on xp but not on the linux mentioned above. FYI, The 3.3.x stream is now dormant. Any fix would have to go into a 3.4.x release. SSQ, if you import the attached projects as existing projects into your workspace (note you need a 1.5 JRE) and run Eclipse, you will find a view called "Nice!" which contains a JTable. Right click on a row, and you will see that there is no popup menu shown. Note I was able to reproduce this in 3.4 RC3. I have the same problem and I tried using the 3.4 release (swt-3.4-gtk-linux-x86.zip) but it doesn't fix the problem -- setting visible an swt menu does not show it. I found a strange quirk however: if I bring that window out of focus, then right-click inside that window when it's out of focus, the menu will show.
My code scenario is as follows: I have an awt Canvas embedded inside an swt Composite (SWT_AWT.new_Frame(myComposite).add(myCanvas)), and I add an awt mouse listener to the canvas. When a right-click is received in that listener it tries to open the menu. It works on Windows XP fine but not on Linux. Here's the code:
public Menu(final Composite composite,
final Canvas canvas) {
menu = new org.eclipse.swt.widgets.Menu(composite);
composite.setMenu(menu);
canvas.addMouseListener(new MouseListener() {
public void mouseClicked(
final MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
try {
composite.getDisplay().syncExec(new Runnable() {
public void run() {
mousePoint.x = e.getX();
mousePoint.y = e.getY();
Point p2 = composite.getDisplay().map(composite,
null,
mousePoint);
menu.setLocation(p2);
System.out.println("menu: set-location="+p2.x+','+p2.y);
composite.getShell().setFocus();
menu.setVisible(true);
System.out.println("menu: visible="+menu.isVisible());
}
});
} catch (Exception x) {
Utility.log(x);
}
}
...
This is an issue that we encountered and worked around in the Albireo project (http://www.eclipse.org/albireo). You may want to consider downloading and using the current alpha release to see if it solves the problem (and perhaps others) for you. Otherwise, perhaps you could take a look at some of the code to see how the problem was worked around. In my experience, SWT popup display needs to be delayed on Gtk until the mouse is released. See this post for more information: http://dev.eclipse.org/mhonarc/lists/albireo-dev/msg00156.html Is this bug still reproducible on a 4.8 I-build? No response in a long time. Please file a new bug against 4.8 if you experience this issue in M6 on GTK3.22. |