Setting checkbox and radio button state

Clicking on a checkbox or a radio button with pointer button #1 changes its state. Checkboxes flip between an on and off state. A radio button always gets set to the on state, turning off the previous radio button in its group to the off state. Checkboxes and radio buttons also handle keyboard input focus. Tabbing to a checkbox or a radio button draws a thin focus frame around it; with SPACE or ENTER setting the checkbox's or the radio button's state.

set_state() directly sets the checkbox's or the radio button's state:


set_state(1) turns on the checkbox or the radio button, set_state(0) turns off the checkbox. Radio buttons should not be turned off directly. Turning on another radio button in the same radio group automatically turns off the currently turned on radio button.

Checkboxes also respond to set_state(2), which is defined as an intermediate state. Only set_state() can set the intermediate state, it cannot be set by clicking on the checkbox.