Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363176 - Popup menu is shown on contained widget
Summary: Popup menu is shown on contained widget
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.5 M5   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: sr142
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-08 09:25 EST by Rüdiger Herrmann CLA
Modified: 2012-01-25 06:39 EST (History)
1 user (show)

See Also:


Attachments
revised patch for 1.4 branch (6.38 KB, patch)
2012-01-24 06:05 EST, Tim Buschtoens CLA
rsternberg: review+
rsternberg: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.