Community
Participate
Working Groups
That summary was a mouthful so here's the code to reproduce the problem. The idea here is that if you invoke setFocus() on a Control before it's set to a CTabItem, the folder will arbitrarily take that request and select the item at index 0. -------------- Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setSize(600, 400); shell.open(); CTabFolder folder = new CTabFolder(shell, SWT.BORDER); for (int i = 0; i < 4; i++) { CTabItem item = new CTabItem(folder, SWT.CLOSE); item.setText("Item " + i); Text text = new Text(folder, SWT.MULTI); text.setText("Content for Item " + i); if (i == 3) { text.setFocus(); } item.setControl(text); } shell.layout(true, true); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); -------------- If setControl(Control) is invoked _before_ setFocus() is called on the control, then it will not eagerly select item 0. -------------- Here's a stack trace of what I hit when debugging through e4 code. StackRenderer$5.widgetSelected(SelectionEvent) line: 409 TypedListener.handleEvent(Event) line: 228 EventTable.sendEvent(Event) line: 84 CTabFolder(Widget).sendEvent(Event) line: 1050 CTabFolder(Widget).sendEvent(int, Event, boolean) line: 1074 CTabFolder(Widget).sendEvent(int, Event) line: 1059 CTabFolder(Widget).notifyListeners(int, Event) line: 773 CTabFolder.setSelection(int, boolean) line: 2722 CTabFolder.onFocus(Event) line: 1306 CTabFolder$1.handleEvent(Event) line: 253 EventTable.sendEvent(Event) line: 84 CTabFolder(Widget).sendEvent(Event) line: 1050 CTabFolder(Widget).sendEvent(int, Event, boolean) line: 1074 CTabFolder(Widget).sendEvent(int) line: 1055 CTabFolder(Control).sendFocusEvent(int) line: 2597 CTabFolder(Widget).wmSetFocus(int, int, int) line: 2399 CTabFolder(Control).WM_SETFOCUS(int, int) line: 4771 CTabFolder(Control).windowProc(int, int, int, int) line: 4208 Display.windowProc(int, int, int, int) line: 4843 OS.SetFocus(int) line: not available [native method] CTabFolder(Control).forceFocus() line: 978 CTabFolder(Control).setFixedFocus() line: 2959 CTabFolder(Composite).setFixedFocus() line: 1039 Composite(Control).fixFocus(Control) line: 936 Composite(Control).setVisible(boolean) line: 3386 CTabItem.setControl(Control) line: 301 StackRenderer.createTab(MElementContainer<MUIElement>, MUIElement) line: 277
I forgot to mention that this problem is not "new" per se. It happens on M3 (I20091030-1201) and I20100309-0100.
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. If the bug is still relevant, please remove the "stalebug" whiteboard tag.