Project: SWT
Bug 93664 TRAVERSE_RETURN closing a dialog cannot be suppressed in a combo box
Reported: 2005-05-04 12:16:56 | Status: resolved fixed

If you run the following snippet and hit "ESC", you will get "Busted" on GTK+ but not on Windows XP. Basically, the traverse listener on the dialog is trying to block escape traversal, but it doesn't seem to work in the case where a combo box has focus. (A similar dialog without combo box seems to work properly.) Display display = new Display(); final Shell shell = new Shell(display); Button b = new Button(shell, SWT.PUSH); b.setText("Open Dialog ..."); b.pack(); b.setLocation(10, 10); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Shell dialog = new Shell(shell, SWT.DIALOG_TRIM); Combo c = new Combo(dialog, SWT.DROP_DOWN | SWT.BORDER); c.pack(); c.setLocation(10, 10); Button b = new Button(dialog, SWT.PUSH); b.setText("Enter"); b.pack(); b.setLocation(100, 100); dialog.setDefaultButton(b); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("Busted"); } }); dialog.addListener(SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.detail == SWT.TRAVERSE_RETURN) { e.doit = false; } } }); dialog.open(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose();

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java