Checkbox objects can clicked (i.e., selected or deselected) by the user.

The following function creates a new Checkbox, so you need to save each in a unique variable (so you can use them later).

Function Description
Checkbox(text, function) Creates a new checkbox with the specified text label (a string) and a function (optional) to be called everytime the checkbox changes state.  If provided, this function should expect one parameter (boolean – signifies the changed state of the checkbox – True means checkbox was just checked, False means checkbox was just unchecked).

For example, a checkbox may be created as follows:

Once a Checkbox has been created, it may be added to a Display specifying where to place its top-left corner.

If you create a Checkbox without using a callback function, then it is a passive GUI element.  In other words, a different part of your program needs to check the state (selected, deselected) of the Checkbox.  This can be done using the following functions:

Function Description
checkbox1.isChecked() Returns Trueif checkbox1 is checked, Falseif unchecked.
checkbox1.check() Sets checkbox1 (i.e., makes it appear checked).
checkbox1.uncheck() Clears checkbox1 (i.e., makes it appear unchecked).

If you create a Checkbox with a callback function, then that function will be called anytime the changes state (checked, unchecked) by the user.  The function should accept one parameter.