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 |
---|---|---|
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. |
Display Units | display_units_text |
Show units after the number on the view. |
Display Units (Label) | display_units_label |
Show units after the label on the view. |
Prefix Text | prefix_text |
Text to display before the value. |
Postfix Text | postfix_text |
Text to display after the value. |
Limits | limits |
Set up alarm limits for this gauge. |
Show Value | show_value |
|
Show Label | show_label |
|
Label Font | label_font |
|
Value Font | value_font |
|
Value Height % | value_height_percent |
A value of zero disables auto font size fitting if Value Height Max is set |
Value Height Max [dp] | value_height_max_dp |
Maximum font height of the value text, in device pixels |
Label Height % | label_height_percent |
|
Label Height Max [dp] | label_height_max_dp |
Maximum font height of the label, in device pixels |
Label Text | label_text |
|
Label Align | label_align |
|
Label Vertical Align | label_valign |
|
Value Align | value_align |
|
Value Vertical Align | value_valign |
|
Low Limit Text | low_limit_text |
|
High Limit Text | high_limit_text |
|
Value Override Text | value_text |
|
Max length Text | max_length_text |
Leave blank for auto |
Background | bg_colour |
Background colour |
Text | text_colour |
Text colour |
Alarm Low Background | alarm_low_bg_colour |
Alarm Lower Limit Background colour |
Alarm Low Text | alarm_low_text_colour |
Alarm Lower Limit Text colour |
Alarm High Background | alarm_high_bg_colour |
Alarm Upper Limit Background colour |
Alarm High Text | alarm_high_text_colour |
Alarm Upper Limit Text colour |
Input Value | parameter |
The source of the value that will be displayed by the gauge. |
Update Rate | update_rate |
Rate at which the input value is requested from the ECU. |
Decimal Places | decimal_places |
Set to -1 for auto |