PB help for CheckBoxGadget() wrote:
By clicking on the checkbox, the user can bring it back to either the "on" or "off" state to apply this to all the items. Therefore the "inbetween" state can only be set by the program via SetGadgetState() and not by the user by clicking on the checkbox.
As a workaround for cycling through all 3 states when clicking onto the
CheckBoxGadget it's not necessary to use API functions. The following
example works cross-platform (tested on Windows 7 x86, Kubuntu 9.04,
Xubuntu 10.04 and MacOS X 10.6.8 ):
Code:
OpenWindow(0, 270, 100, 270, 40, "Cycle through CheckBox states")
CheckBoxGadget(0, 10, 10, 250, 20, "3-state CheckBox", #PB_CheckBox_ThreeState)
CheckBoxState = 1
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0
CheckBoxState = (CheckBoxState + 1) % 3
If CheckBoxState = 2
SetGadgetState(0, #PB_Checkbox_Inbetween)
EndIf
EndIf
EndSelect
ForEver