Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top