| Summary: | [Custom Widgets] CCombo setFocus does not work | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Martin Kalina <martin.kalina> | ||||
| Component: | SWT | Assignee: | Lakshmi P Shanmugam <lshanmug> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | carolynmacleod4, martin.kalina, oleg.v.danilov | ||||
| Version: | 4.0 | ||||||
| Target Milestone: | 3.7 M6 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Martin Kalina
Snippet showing the problem: public class Bug320636 { public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Text textbox = new Text(shell, SWT.SINGLE | SWT.LEAD | SWT.BORDER); textbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); textbox.setText("textbox"); CCombo combo = new CCombo(shell, SWT.FLAT | SWT.BORDER); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); for (int i = 0; i < 5; i++) { combo.add("item" + i); } combo.setText("item0"); combo.setFocus (); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Created attachment 188310 [details]
patch
CCombo.setFocus() should set focus on the text and this happens when text.setFocus() is called. But, we return before text.setFocus() is called because the CCombo's parent is not yet visible and isVisible() returns false.
The patch uses getVisible() instead of isVisible().
Carolyn, can you please review the patch?
Looks good, Lakshmi - go for it! Thanks Carolyn! Fixed in HEAD > 20110209 |