Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » GtkToggleButton selected background color
GtkToggleButton selected background color [message #1851240] Thu, 31 March 2022 15:09
Tom Wheeler is currently offline Tom WheelerFriend
Messages: 17
Registered: June 2018
Junior Member
I am developing an Eclipse-4 RCP application running atop eclipse-rcp-2021-12-R. When executing the application on CentOS 7.2 (libgtk-3.so.0.2200.30), we hardly see any difference in the background of a toggle button when it is toggled in or out and we receive customer complaints about this issue.

Does anybody know why there is so little difference?

In ~/.config/gtk-3.0/gtk.css, I added this:
button:checked {
	color: #ff0000;
	background-color: #0000ff;
}


And I created this main program to test:
public class Toggle {

    private final GridDataFactory aFillGdf = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false));

    public void doStuff() {

        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        shell.setSize(600, 400);

        Button button = WidgetFactory.button(SWT.TOGGLE).text("sometext").layoutData(aFillGdf.create()).create(shell);
//        button.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));

        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    }

    public static void main(String[] args) {
        Toggle toggle = new Toggle();
        toggle.doStuff();
    }
}


Now, when "button.setBackground()" is commented out, the "background-color" from gtk.css has no effect. So the background has an almost invisible change when the button is toggled in.

However, if "button.setBackground()" is in effect, even if it is applying the default background color that the button already has (SWT.COLOR_WIDGET_BACKGROUND), the "background-color" attribute from gtk.css is indeed effective when the button is toggled in.

Does anybody know why we have to do such magic to have the background color change when the button is toggled in?

Is there a simpler way to enforce a more visible change in background color when a toggle button is toggled in?
Previous Topic:Indeterminate progress bar animation problem on Linux
Next Topic:Console Plugin Pops Error Dialogs
Goto Forum:
  


Current Time: Mon May 06 13:30:21 GMT 2024

Powered by FUDForum. Page generated in 0.02959 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top