Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make RCP toggle button state more visible?

I have some toggle buttons declared like this :

button = new Button(this, SWT.TOGGLE);
button.setImage(icon);

They look like this on my computer :

enter image description here

The right one is pushed, the left one isn't.

But on some computers, depending on the general settings of the OS, it may be hard to see if the button is pushed.

What can I do to make the button's state more visible, independently of the OS settings ?

I precise the application uses the Eclipse 3 platform and that I need this to work on any Desktop Windows starting from XP.

like image 643
Denys Séguret Avatar asked Jan 31 '26 17:01

Denys Séguret


1 Answers

As I didn't find any clean solution (one which would work for all buttons without having to duplicate all icons), I did as suggested by Alexander :

    button.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
        }
        public void widgetSelected(SelectionEvent e) {
            button.setImage(button.getSelection() ? pushedIcon : icon);
            ...
        }           
    });

It looks like this :

enter image description here

On computers with bad color settings (e.g. grey for selection), this will be an improvement.

like image 176
Denys Séguret Avatar answered Feb 02 '26 08:02

Denys Séguret