[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Missing ModifyEvent after switching parents with setParent()

Hi,

I shrink the example towards the core of the problem.
If you dispose the old shell after switching the parents by setParent(), no modify events are every fired, doesn't matter when you add the listener (here adding the listener after the old shell was disposed).
So shell disposing seems to destroy sth fundamental in modify event handling, after switching parents, while other event handlings work without any problems... Any ideas?


public static void main(String[] args) throws Exception {

	// listen to all MODIFY Events -> output on console
	Display.getDefault().addFilter(SWT.Modify, new Listener() {

		public void handleEvent(Event event) {
			System.out.println("Modify");
		}
	});
	
	// creating old Shell
	Shell shell = new Shell(Display.getDefault());
	shell.setSize(1000, 700);
	shell.setText("OldShell");
	shell.setLayout(new FillLayout());

	// creating Text
	final Text t = new Text(shell, SWT.SINGLE | SWT.BORDER);

	// creating new Shell
	Shell newShell = new Shell(Display.getDefault());
	newShell.setText("NewShell");
	newShell.setLayout(new FillLayout());
	newShell.setSize(300, 200);

	// switching parents
	t.setParent(newShell);

	// disposing old Shell
	shell.dispose();

	// add modifylistener to Text -> here is the error
	t.addModifyListener(ml);

	newShell.open();
	while (!newShell.isDisposed()) {
		if (!Display.getDefault().readAndDispatch())
			Display.getDefault().sleep();
	}

	Display.getDefault().dispose();
	System.exit(0);
}

thanks, Johannes