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

Bug 311975

Summary: Approach described in Snippet46 doesn't seem to work for complex widget hierarchies
Product: [Eclipse Project] Platform Reporter: Brian de Alwis <bsd>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe
Version: 4.0   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:

Description Brian de Alwis CLA 2010-05-06 17:03:15 EDT
Build-Id: 3.6 M7'ish (as provided with recent builds of e4)

I was trying the approach described in the SWT Snippet #46 to detect double-clicks in a populated composite.  I've added a bunch of other widgets to Snippet46, including nested Composites and Groups, with assorted callbacks, and it continue to work.

Unfortunately this approach (attaching a listener to the shell) doesn't work for an Eclipse view.  I'm not sure what's different about this situation, nor what is necessary to get the equivalent behaviour.

Steps to repeat:
1. From Eclipse, create a new view plugin (File > New > Plugin Project > ... > Plug-in with a view.
2. Open the view's SampleView.java.  Add the following at the bottom of the createPartControl() method:

		parent.getShell().addListener(SWT.MouseDoubleClick, new Listener() {
			public void handleEvent(Event event) {
				System.out.println("MouseDoubleClick");
			}});
		parent.getShell().addListener(SWT.MouseMove, new Listener() {
			public void handleEvent(Event event) {
				System.out.println("MouseMove");
			}});

On MacOS X, I see "MouseMove" only when the cursor is on the titlebar or at the very fringes of the window borders.  I never see "MouseDoubleClick" printlns.
Comment 1 Felipe Heidrich CLA 2010-05-07 09:18:37 EDT
Do you know that the shell is only getting the events because the composite is disabled, right ?

You can also use Display#addFilter to get all the events in the display.

Please reopen this problem when you cause the problem to fail in the snippet.
(I don't have any indication that you calling setEnable(false) for a composite and listening for mouse events in the composiste's parent).