Community
Participate
Working Groups
When you call the select() method on the Combo widget on Windows, no selection event is fired. However, on Linux, a selection event is fired. It doesn't matter if select() is called before or after the widget is visible. In the following testcase, the call to select() does not cause the message to be printed to the console on Windows. It does, however, on Linux. Even moving the select() call before the shell.open() causes the same results.
example code ============ import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; //------------------------------------------------------------------- // //------------------------------------------------------------------- public class PR_5056 { private Display display; private Shell shell; private Combo c; //------------------------------------------------------------------- // //------------------------------------------------------------------- static public void main(String[] args) { new PR_5056().runMain(args); } //------------------------------------------------------------------- // //------------------------------------------------------------------- private void runMain(String[] args) { display = new Display(); shell = new Shell(display); shell.setText(getClass().getName()); shell.setBounds(0,0,200,200); shell.setLayout(new GridLayout()); c = new Combo(shell,SWT.DROP_DOWN | SWT.READ_ONLY); c.add("Item 1"); c.add("Item 2"); c.add("Item 3"); c.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { public void widgetSelected (org.eclipse.swt.events.SelectionEvent e) { // on Windows, this is not invoked by the Combo.select () call System.out.println(c.getSelectionIndex()); } }); shell.open(); c.select(0); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } ==== Let me add that I prefer the Windows behavior over the Linux behavior :-) }
The behavior should be made consistant between platforms if possible.
Actually the fix for this was already made last week and will be in this morning's build. Both platforms now behave like Windows. *** This bug has been marked as a duplicate of 4910 ***