|Introduction | Your first interface | Building a model | Advanced features | Resources|
4.3 Checkboxes and options
This section explains how to implement checkboxes and option buttons within a simulation. The model and interfaces used in this section can be downloaded here: trainingCheckbox.zip.
Checkboxes and option buttons are implemented with the same control - the checkbox. This control is accessible from the Object menu or toolbar (it can't be accessed by a right-click in the property tree). The difference between checkboxes and option buttons is that options in a group are mutually exclusive - if one is selected then the others cannot be. Checkboxes is a group can be selected independently of each other.
A group of checkboxes or option buttons display an array of strings, and use a separate array of strings to store items that are selected. In the example below there is a group of checkboxes (food) and option buttons (drink) and a table associated with each that shows how the arrays of selected items change. A series of overlays and trigger conditions are used to decide which items of food are displayed, based on the contents of the selected array (this is done with a string-parsing routine in the underlying model).
The modelCheckValues property must be linked to an array of strings, which has the button values contained in it. To get information on the selected items the modelSelectValues property must be linked to a separate array of strings, which is used to hold information about which items are selected. This information can then be extracted and used (in the example it's used to set a boolean value associated with each food item). The userCheckValues can be used to set the values to be displayed directly by the interface designer rather than basing them on a model property, but this property will be overridden by the modelCheckValues property if it's set.
If the exclusive property is set to false, checkboxes will be displayed, if true, option buttons will be used.