Community
Participate
Working Groups
Run the following code. As the shell is activated/deactivated the combo gains and loses focus. Select the "dispose this combo" item in the combo. The combo gets disposed and the shell does not get focus. Deactivating/Activating the shell doesn't help. There are no more focus events. public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Shell"); final Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "do nothing", "dispose this combo" }); Point size = combo.computeSize(-1, -1); combo.setBounds(5, 5, size.x, size.y); combo.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (combo.getSelectionIndex() == 1) combo.dispose(); } }); Listener listener = new Listener() { public void handleEvent(Event event) { String type = event.type == SWT.FocusIn ? "FocusIn" : "FocusOut"; System.out.println(type + " " + event.widget); } }; shell.addListener(SWT.FocusIn, listener); shell.addListener(SWT.FocusOut, listener); combo.addListener(SWT.FocusIn, listener); combo.addListener(SWT.FocusOut, listener); shell.setSize(300, 200); shell.open(); while (!shell.isDisposed()) { boolean dispatch = display.readAndDispatch(); if (!dispatch) display.sleep(); } display.dispose(); }
Please investigate for RC1. SSQ and I played with the focus code recently to fix focus in/out of combos so this is probably a regression.
The same thing happens on 3.2. It has nothing to do with Combo. If you never put controls on a shell, the shell will send focus events. If you put any controls on a shell, focus events won't be sent from the shell, even if you dispose all of the child controls.
Praveen to investigate.
Created attachment 121341 [details] Patch to set Focus of shell when it's children are disposed Patch of Bug 227261 will address the reported problem. I am attaching the patch once again here.
This is still reproducible.
Patch done in Bug 69650 should fix focus issues, however this one is a unique case; "focus" is determined by if the widget has keyboard focus or not. When selecting an item in the combobox (AKA opening up the dropdown items list), the combobox is not in focus anymore. Thus, when clicking the dispose item, nothing ends up being focused after that as there was no focused item in the first place. This is a very special case for this bug to happen (disposing a combobox cuased by an dropdown item).
*** This bug has been marked as a duplicate of bug 69650 ***