Checkbox


Checkbox(b)

Defines a variable or table cells to be a checkbox true/false input. The parameter «b» must be a literal value, either 0 or 1. When the user views the definition, or when an input control is created for the variable, the definition displays as a checkbox control -- either an empty square (unchecked) or a square with a checkmark (checked).

When the user clicks on the checkbox control, the value is toggled from 0 (unchecked) to 1 (checked).

To define a variable as a checkbox, you must type the expression directly into the definition field (e.g., Checkbox(0)). Once entered, it will display as a checkbox when viewing the definition field. Typically you would then create an input control for the variable (since the purpose of this function is to provide your users when a checkbox on a form).

Checkboxes in tables

To define a cell in a table as a checkbox control, view the table from edit mode and then type Checkbox(0). It will immediately display as a checkbox control as soon as you enter the expression. An expression-control selector appears along the right edge of the table window, near the top, once the control displays. If you need to change or remove the textual expression, use this control to select Show expressions' from edit mode. In browse mode, the cells will always display as controls. The checkbox control will be disabled in browse mode unless your table node also has an input node associated with it.

In many cases, you may want have all cells in the table be checkboxes. In this case, you should set the Table Cell Default to be Checkbox(0). By doing so, when new cells are added to the table (as a result of index lengths changing, or of new indexes being added to the table), the new cells will automatically start out as checkboxes. You can do this from the Attribute pane or from the Object window.

  1. Make sure you are in Edit mode.
  2. In the Object window, if the Cell Default attribute is not showing, show the attribute by clicking the hover icon in the lower left corner and selecting it on the menu.
  3. From the Attribute pane, select Cell Default on the attribute menu. It may be in the More» submenu.
  4. Set the attribute value to: Checkbox(0)
  5. View the edit table. If cells were previously populated with 0, select them and select Reset selected to default on the right-mouse context menu.

Examples

A diagram containing a checkbox. Pay_bonus is defined as Checkbox(1):

Diagram with checkbox.jpg

A table containing checkbox controls. Each cell in the Cogen column is defined as Checkbox(0) or Checkbox(1).

Table with checkboxes.jpg

Notes

When copy/pasting into a table containing checkboxes, if the source data contains values 0, 1, "yes", "no", "true", or "false", the control will remain as a check and just change the current state to match the incoming data. If the source data contains something dramatically different (e.g., 17.3), then the control will be replaced by the value.

If you specify a script attribute for a variable defined using Checkbox, the typescript in that attribute will be executed whenever the user clicks on the control to change its state.

Limitations

A checkbox provides only a scalar option (true/false). Unlike a Choice pulldown, you do not have an All option to propagate both options through the model. For that option, you'll still need to revert to a Choice.

On a checkbox input control, there is not an option to place the checkbox to the left of the label. If you want this layout, you use Set Node Style... to turn off the label on the input control, and then place a text node with the label to the right of the check.

Checkboxes only display for input controls. You can't use a checkbox to present result information in an output control or result table.

As with other input controls, there is no disabled state (i.e., where the control is visible on a form with a grayed-out appearance, and doesn't respond to user input).

History

Checkbox was introduced in Analytica 4.2.

See Also

Comments


You are not allowed to post comments.