Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 185538 - No focus events after combo disposed
Summary: No focus events after combo disposed
Status: CLOSED DUPLICATE of bug 69650
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.7   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ian Pun CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-04 09:17 EDT by Kevin Barnes CLA
Modified: 2016-09-12 09:54 EDT (History)
5 users (show)

See Also:


Attachments
Patch to set Focus of shell when it's children are disposed (1.77 KB, patch)
2008-12-30 08:48 EST, Praveen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Barnes CLA 2007-05-04 09:17:15 EDT
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();
	}
Comment 1 Steve Northover CLA 2007-05-11 09:17:51 EDT
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.
Comment 2 Kevin Barnes CLA 2007-05-11 10:45:32 EDT
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.
Comment 3 Bogdan Gheorghe CLA 2008-12-22 14:10:01 EST
Praveen to investigate.
Comment 4 Praveen CLA 2008-12-30 08:48:13 EST
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.
Comment 5 Eric Williams CLA 2016-08-22 12:10:48 EDT
This is still reproducible.
Comment 6 Ian Pun CLA 2016-09-07 17:15:35 EDT
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).
Comment 7 Ian Pun CLA 2016-09-12 09:54:16 EDT

*** This bug has been marked as a duplicate of bug 69650 ***