| Summary: | Giving focus to other control during FocusIn doesn't reassign the Caret | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Felipe Heidrich <eclipse.felipe> |
| Component: | SWT | Assignee: | Felipe Heidrich <eclipse.felipe> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | snorthov |
| Version: | 3.4 | ||
| Target Milestone: | 3.5 M1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Felipe Heidrich
Snippet:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class PR237675 {
public static void main(String[] args) {
Display display = new Display ();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
Canvas canvas = new Canvas(shell, SWT.NONE);
Caret caret = new Caret(canvas, SWT.NONE);
caret.setSize(1, 11);
canvas.setCaret(caret);
final Text text = new Text(shell, SWT.BORDER | SWT.SINGLE);
canvas.addListener(SWT.Paint, new Listener() {
public void handleEvent(Event event) {
event.gc.drawText("This is a FormText field with a Caret.", 0, 0, 0);
}
});
canvas.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
//allow the canvas take focus
}
});
canvas.addListener(SWT.FocusIn, new Listener() {
public void handleEvent(Event event) {
text.setFocus();//causes the bug
}
});
shell.setSize(250, 200);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Problem originally detected on Bug 236735 Fixed in HEAD > 20080618 (post 3.4) Steve, I only added the fix in WM_SETFOCUS The fix in WM_KILLFOCUS would be: if (caret != null && !caret.isFocusCaret ()) caret.killFocus(); But that is not necessary cause, even if you kill the current caret that belongs to another control, that will get fixed during the WM_SETFOCUS that follows. |