Checkbox
The CheckBox View provides a configurable check box that may be used to execute scripts when it is clicked or changes state, and allows advanced configuration/control templates to be constructed.
CheckBox scripts should define an onClick and/or an onChanged function that is called when the checkbox is clicked or changed state. The default script for a newly added checkbox should contain an empty implementations of these functions ready to be filled in.
Example script:
function onSetValue(checked)
{
var edit = window.findViewByID("some_editor");
edit.enabled = checked;
}This script enables another control with the script ID 'some_editor' when the checkbox changed value either through clicking it or when another script changed its value.
To make the checkbox interact with an option:
// Get a reference to the option of interest.
var barocorr = gin.options.find("Baro Correction");
function onGetValue()
{
// Get the value of the on/off option.
return barocorr.getReal();
}
function onSetValue(checked)
{
// Set the value of the on/off option.
barocorr.setReal(checked);
}When accessed via scripts, the checkbox text can be accessed by the 'text' property and its value by the 'checked' property:
var cb = window.findViewByID("my_checkbox");
cb.text = "Bingo";
cb.checked = !cb.checked; // Toggle value
Checkboxes define the following global variables in their scripts:
'ecu', of type Ecu.
'gin', [deprecated] Alias of def property. See Ecu for details.
'window' of type Window.
'view' of type CheckBox. This a reference to 'this', for convenience and readability.
View Properties
Properties editable via the properties editor.
| Property | Script ID | Description |
|---|---|---|
| Label | label |
Sets the check box label. |
| Exclusion Group | exclusion_group |
Mutual exclusion group (Radio Group). Only a single control within the same exclusion group may be checked. |
| Script | script |
Edit the script for custom actions / value calculation. |
| Title | title |
The title of the window. |
| Script ID | id |
The scripting ID of the window. Can be used as an alternative to the title for searching for windows from scripts. |
| Tool Tip | tooltip |
Window tool tip. |
| Label | label |
Sets the button label. |
| Font Size | font_size |
Size of the text. |