Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363176

Summary: Popup menu is shown on contained widget
Product: [RT] RAP Reporter: RĂ¼diger Herrmann <ruediger.herrmann>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: unspecified   
Target Milestone: 1.5 M5   
Hardware: All   
OS: All   
Whiteboard: sr142
Attachments:
Description Flags
revised patch for 1.4 branch rsternberg: review+, rsternberg: review?

Description RĂ¼diger Herrmann CLA 2011-11-08 09:25:03 EST
In the following snippet there is a popup menu added to the shell but not the the Composite 'c1'.
Nevertheless, when clicking on 'c1' there is a popup menu shown.

public class Snippet40 implements IEntryPoint {

public int createUI() {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(2, false));
	
	Composite c1 = new Composite(shell, SWT.BORDER);
	c1.setLayoutData(new GridData(100, 100));
		
	Menu menu = new Menu(shell, SWT.POP_UP);
	MenuItem item = new MenuItem(menu, SWT.PUSH);
	item.setText("Popup");
		
//		c1.setMenu(menu);
	shell.setMenu(menu);
	
	shell.setSize(300, 300);
	shell.open();
	return 0;
}
}
Comment 1 Ivan Furnadjiev CLA 2011-12-22 08:06:22 EST
The problem is the following:
1. stopPropagation and preventDefault are *only* called in Menu.js#contextMenuHandler when the event is consumed (there is a popup menu to show).
2. Event listeners ( keydown/mouseup ) are not attached in AdapterUtil.js menu handler if there is no menu set. Thus, even if we fix the p.1, this code will not be executed as there are no listeners attached to the widget without a context menu.
Comment 2 Tim Buschtoens CLA 2012-01-05 10:00:23 EST
Fixed in CVS HEAD by always getting the menu from the first control in the hierarchy.
Comment 3 Tim Buschtoens CLA 2012-01-24 06:05:49 EST
Created attachment 209961 [details]
revised patch for 1.4 branch

Same fix for the 1.4.2 release.
Comment 4 Ralf Sternberg CLA 2012-01-25 04:50:07 EST
Comment on attachment 209961 [details]
revised patch for 1.4 branch

I think the patch is fine. Ivan, please have a look at it, too.
Comment 5 Ivan Furnadjiev CLA 2012-01-25 06:39:42 EST
Patch looks OK to me too. Applied patch to v14_Maintenance branch.