Tri-state Checkbox

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Tri-state Checkbox

Thomas Singer
Hi,

It looks like a checkbox can work in 2 different modes, either toggling
between selected and unselected, and toggling between tri-state and
unselected. So my understanding it that to set it programmatically to
the tri-state mode, I have to invoke

   checkbox.setGrayed(true);
   checkbox.setSelection(true);

How can I make it switch between selected - unselected - tri-state using
the mouse? Or should I simulate it myself using mouse-click-listeners?

--
Best regards,
Thomas Singer
=============
syntevo GmbH
http://www.syntevo.com
http://www.syntevo.com/blog
_______________________________________________
platform-swt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tri-state Checkbox

Conrad Groth
Hi Thomas,

there is a SWT snippet showing the desired behaviour:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org
.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet315.java

Best regards
Conrad

-----Urspr√ľngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Thomas Singer
Gesendet: Montag, 24. Juli 2017 20:13
An: [hidden email]
Betreff: [platform-swt-dev] Tri-state Checkbox

Hi,

It looks like a checkbox can work in 2 different modes, either toggling
between selected and unselected, and toggling between tri-state and
unselected. So my understanding it that to set it programmatically to the
tri-state mode, I have to invoke

   checkbox.setGrayed(true);
   checkbox.setSelection(true);

How can I make it switch between selected - unselected - tri-state using the
mouse? Or should I simulate it myself using mouse-click-listeners?

--
Best regards,
Thomas Singer
=============
syntevo GmbH
http://www.syntevo.com
http://www.syntevo.com/blog
_______________________________________________
platform-swt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tri-state Checkbox

Thomas Singer
Hi Conrad,

Thank you for this information. I have implemented it similarly, but
wonder why there is no method in SWT's Button class to set the
listeners. Something along the lines:

public void installTriStateToggling() {
        addListener (SWT.Selection, e -> {
                if (button.getSelection()) {
                        if (!button.getGrayed()) {
                                button.setGrayed(true);
                        }
                } else {
                        if (button.getGrayed()) {
                                button.setGrayed(false);
                                button.setSelection (true);
                        }
                }
        });
}

--
Best regards,
Thomas Singer
=============
syntevo GmbH
http://www.syntevo.com
http://www.syntevo.com/blog


On 2017-07-24 20:57, Conrad Groth wrote:

> Hi Thomas,
>
> there is a SWT snippet showing the desired behaviour:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org
> .eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet315.java
>
> Best regards
> Conrad
>
> -----Urspr√ľngliche Nachricht-----
> Von: [hidden email]
> [mailto:[hidden email]] Im Auftrag von Thomas Singer
> Gesendet: Montag, 24. Juli 2017 20:13
> An: [hidden email]
> Betreff: [platform-swt-dev] Tri-state Checkbox
>
> Hi,
>
> It looks like a checkbox can work in 2 different modes, either toggling
> between selected and unselected, and toggling between tri-state and
> unselected. So my understanding it that to set it programmatically to the
> tri-state mode, I have to invoke
>
>     checkbox.setGrayed(true);
>     checkbox.setSelection(true);
>
> How can I make it switch between selected - unselected - tri-state using the
> mouse? Or should I simulate it myself using mouse-click-listeners?
>
> --
> Best regards,
> Thomas Singer
> =============
> syntevo GmbH
> http://www.syntevo.com
> http://www.syntevo.com/blog
> _______________________________________________
> platform-swt-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
> _______________________________________________
> platform-swt-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
_______________________________________________
platform-swt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev