| Summary: | setBackgroundColor fails/delayed within Combo's ModifyListener trigger | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | ArronM <arronm> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | christian.campo, cocoakevin, elias, grant_gayed, lshanmug |
| Version: | 3.6 | Keywords: | triaged |
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X | ||
| Whiteboard: | stalebug | ||
The field editor isn't getting the background color on 10.6 only. I tried forcing it, but didn't improve anything. NSTextField has the same bug (ie Text with SWT.SINGLE). Here is a snippet to reproduce it with the Text widget:
public final class SnippetText001 {
public static void main(String[] args) {
Display display = Display.getDefault();
try {
Shell shell = new Shell();
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).spacing(20, 10).applyTo(shell);
createLabel(shell, "Input (>5):"); //$NON-NLS-1$
final Text text = new Text(shell, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(text);
createLabel(shell, "Output:"); //$NON-NLS-1$
Label label = createLabel(shell, ""); //$NON-NLS-1$
GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
final Color oldBackground = text.getBackground();
text.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (text.getText().length() > 4) {
text.setBackground(oldBackground);
}
}
});
Button button = new Button(shell, SWT.NONE);
button.setText("click me");
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
text.setBackground(oldBackground);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
shell.setSize(200, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} finally {
display.dispose();
}
}
private static Label createLabel(Shell shell, String caption) {
Label result = new Label(shell, SWT.NONE);
result.setText(caption);
return result;
}
}
When you run it, the Text starts with a yellow background and should become white when you have more than 5 chars or you press the click me button. Both work on windows but not on Mac OS X 10.6.
Tested on 4801 on macOS Sierra 10.12.5 and bug still exists Bug triaged, visit https://wiki.eclipse.org/SWT/Devel/Triage for more information. 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. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. 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. -- The automated Eclipse Genie. |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 Build Identifier: SWT3556b calling setBackgroundColor within the ModifyListener trigger of a Combo does not set the background color until the control loses focus. Works immediately on Windows, and in Carbon (last I checked). Reproducible: Always Steps to Reproduce: Snippet: (type one character, the background should turn blue, type another, it should go back to default, etc. On Cocoa, you have to type one character then tab to next field to get the blue) public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FillLayout(SWT.VERTICAL)); final Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { Color color = combo.getText().length() % 2 == 0 ? null : display.getSystemColor(SWT.COLOR_BLUE); combo.setBackground(color); } }); Text btn = new Text(shell, SWT.PUSH); btn.setText("text to tab to"); shell.open(); combo.setFocus(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }