Bug 265470

Summary: SWT.Deactivate sent twice when hiding the deactivating shell
Product: [Eclipse Project] Platform Reporter: Randy Hudson <hudsonr>
Component: SWTAssignee: Steve Northover <steve_northover>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Randy Hudson CLA 2009-02-19 10:29:41 EST
1) Press the giant button to open a popup shell.
2) Click back on the titlebar of the first shell.

bug: Deactivate event is received twice.

When I found this, my deactivate listener was eventually disposing the shell, which caused problems when I tried to do it twice.

public class ShellSnippet {
	
static final Display display = new Display();
static Shell shell;

public static void main(String[] args) {
	shell = new Shell(display);
	shell.setLayout(new FillLayout());
	shell.setSize(400, 300);
	
	new Button(shell, SWT.PUSH).addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event event) {
			popup();
		}
	});
	
	shell.open();
	while (!shell.isDisposed())
		while (!display.readAndDispatch())
			display.sleep();
}

static void popup() {
	final Shell popup = new Shell();
	popup.pack();
	popup.addListener(SWT.Deactivate, new Listener() {
		public void handleEvent(Event event) {
			System.out.println("Deactivate");
			popup.setVisible(false);
		}
	});
	
	popup.addListener(SWT.Activate, new Listener() {
		public void handleEvent(Event event) {
			System.out.println("Activate");
		}
	});
	
	popup.open();
}

}
Comment 1 Eclipse Webmaster CLA 2019-09-06 16:08:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.