-
Notifications
You must be signed in to change notification settings - Fork 192
Description
Describe the bug
Computed background and foreground colors are only updated in setEnabled(boolean enabled) method.
For consistency they should be recomputed and updated in every method that changes anything on which the computations depend.
Look at the following code in StyledText.java:
public void setEditable(boolean editable) {
checkWidget();
this.editable = editable;
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
Display display = getDisplay();
this.enabled = enabled;
this.insideSetEnableCall = true;
try {
if (enabled && editable) {
if (!customBackground) setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
if (!customForeground) setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
} else if(!enabled) {
if (!customBackground) setBackground(display.getSystemColor(SWT.COLOR_TEXT_DISABLED_BACKGROUND));
if (!customForeground) setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND));
} else if(!editable) {
if (!customBackground) setBackground(display.getSystemColor(SWT.COLOR_TEXT_DISABLED_BACKGROUND));
if (!customForeground) setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
}
}
finally {
this.insideSetEnableCall = false;
}
}As you can see background and foreground colors are updated in setEnabled(boolean enabled), but aren't updated in setEditable(boolean editable) even though the colors depends on the value of enabled.
Ideally, the colors should be recomputed and updated in every method modifying enabled, editable, customBackground or customForeground.
To Reproduce
Not required.
Expected behavior
The background and foreground colors should be recomputed (just like it happens in setEnabled(boolean enabled) now) in every method in StyledText that modifies any field on which the computation depends: enabled, editable, customBackground or customForeground.
Screenshots
Screenshots aren't applicable here.
Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS
-
Additional OS info (e.g. OS version, Linux Desktop, etc)
- -
JRE/JDK version
-
Version since
Since at least eclipse.platform.swt tag R4_39.
Workaround (or) Additional context
-