Skip to content

Commit 9b991c8

Browse files
committed
Restyle Copy Settings check buttons on macOS when section is shown
On macOS Cocoa, setBackground/setForeground applied to a widget that is currently hidden is not retained once the widget is realized. The "Copy Settings" section of ChooseWorkspaceWithSettingsDialog is created with setVisible(false), so the theme-engine colors on its check buttons are dropped and the buttons paint with the default light system colors when the user expands the section on a dark theme. Re-apply the parent background/foreground to the check buttons when the section first becomes visible. Guarded with Util.isMac() since GTK and Windows retain the colors across realize and do not need this workaround. Fixes #3897
1 parent 39cf286 commit 9b991c8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.jface.fieldassist.ControlDecoration;
3535
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
3636
import org.eclipse.jface.resource.JFaceResources;
37+
import org.eclipse.jface.util.Util;
3738
import org.eclipse.osgi.util.NLS;
3839
import org.eclipse.swt.SWT;
3940
import org.eclipse.swt.custom.ScrolledComposite;
@@ -153,6 +154,20 @@ private void createSettingsControls(Composite workArea) {
153154
clientData.exclude = !expanded;
154155
toggle.setText(expanded ? "\u25BE" : "\u25B8"); //$NON-NLS-1$ //$NON-NLS-2$
155156

157+
// On macOS Cocoa, setBackground/setForeground on a hidden widget is dropped
158+
// once the widget is realized. Re-apply colors to the check buttons when
159+
// the section first becomes visible.
160+
if (Util.isMac()) {
161+
sectionClient.addListener(SWT.Show, e -> {
162+
for (Control child : sectionClient.getChildren()) {
163+
if (child instanceof Button button && (button.getStyle() & SWT.CHECK) != 0) {
164+
button.setBackground(workArea.getBackground());
165+
button.setForeground(workArea.getForeground());
166+
}
167+
}
168+
});
169+
}
170+
156171
Listener toggleListener = e -> {
157172
boolean newState = !sectionClient.getVisible();
158173
sectionClient.setVisible(newState);

0 commit comments

Comments
 (0)