Skip to content

Commit bebec37

Browse files
committed
Fix disabled wizard buttons appearing enabled in dark theme
In the dark theme, the CSS sets a foreground color on all Button elements, which overrides the native OS disabled button rendering. This causes disabled buttons (like 'Finish') to look identical to enabled ones. Fix this by setting a 'disabled' CSS class on wizard buttons when they are disabled. The dark theme CSS now includes a Button.disabled rule with a dimmed foreground color. A reskin is triggered on state change so the CSS engine re-applies styles without needing the global dynamic CSS pseudo-class support (which is disabled for performance).
1 parent efb185f commit bebec37

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ private void restoreEnableState(Control control, Map<String,Object> saveState, S
973973
if (control != null) {
974974
Boolean b = (Boolean) saveState.get(key);
975975
if (b != null) {
976-
control.setEnabled(b.booleanValue());
976+
setButtonEnabled(control, b.booleanValue());
977977
}
978978
}
979979
}
@@ -1066,10 +1066,25 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
10661066
private void saveEnableStateAndSet(Control control, Map<String, Object> saveState, String key, boolean enabled) {
10671067
if (control != null) {
10681068
saveState.put(key, control.getEnabled() ? Boolean.TRUE : Boolean.FALSE);
1069-
control.setEnabled(enabled);
1069+
setButtonEnabled(control, enabled);
10701070
}
10711071
}
10721072

1073+
/**
1074+
* Sets the enabled state of a button and updates the CSS class name so that
1075+
* the dark theme can style disabled buttons differently. The CSS class
1076+
* "disabled" is set when the button is disabled, and cleared when enabled.
1077+
* This triggers a reskin so that the CSS engine re-applies styles.
1078+
*
1079+
* @param control the button control
1080+
* @param enabled whether the button should be enabled
1081+
*/
1082+
private static void setButtonEnabled(Control control, boolean enabled) {
1083+
control.setEnabled(enabled);
1084+
control.setData("org.eclipse.e4.ui.css.CssClassName", enabled ? null : "disabled"); //$NON-NLS-1$ //$NON-NLS-2$
1085+
control.reskin(SWT.NONE);
1086+
}
1087+
10731088
/**
10741089
* Captures and returns the enabled/disabled state of the wizard dialog's
10751090
* buttons and the tree of controls for the currently showing page. All
@@ -1332,13 +1347,13 @@ public void updateButtons() {
13321347
boolean canFinish = wizard.canFinish();
13331348
if (backButton != null) {
13341349
boolean backEnabled = currentPage != null && currentPage.getPreviousPage() != null;
1335-
backButton.setEnabled(backEnabled);
1350+
setButtonEnabled(backButton, backEnabled);
13361351
}
13371352
if (nextButton != null) {
13381353
canFlipToNextPage = currentPage != null && currentPage.canFlipToNextPage();
1339-
nextButton.setEnabled(canFlipToNextPage);
1354+
setButtonEnabled(nextButton, canFlipToNextPage);
13401355
}
1341-
finishButton.setEnabled(canFinish);
1356+
setButtonEnabled(finishButton, canFinish);
13421357
// finish is default unless it is disabled and next is enabled
13431358
if (canFlipToNextPage && !canFinish) {
13441359
getShell().setDefaultButton(nextButton);

bundles/org.eclipse.ui.themes/css/dark/e4-dark_globalstyle.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ Group > StyledText {
4545
color:'#org-eclipse-ui-workbench-DARK_FOREGROUND';
4646
}
4747

48+
/* Disabled buttons should appear dimmed to distinguish them from enabled buttons */
49+
Button.disabled {
50+
color: #777777;
51+
}
52+
4853
/* ############################## Toolbar ############################## */
4954
/* Ensure that the labels in the tabfolder gets updated
5055
See Bug 552780

0 commit comments

Comments
 (0)