Button
The Button View provides a configurable button that may be used to execute scripts when it is clicked, and allows advanced configuration/control templates to be constructed.
Button scripts should define an onClick function that is called when the button is clicked. The default script for a newly added button should contain an empty onClick function ready to be filled in.
Example script:
function onClick()
{
var pedal = gin.channels.find("Pedal");
var pedal\_min = gin.options.find("Pedal min");
pedal\_min.setReal(pedal.getReal());
}This script takes the value of the “Pedal” channel and assigns it to the “Pedal Min” option as part of a pedal range configuration page.
When accessed via scripts, the button text can be accessed by the ’text’ property:
var b = window.findViewByID("my\_button");
print(b.text);
b.text = "Bingo";Buttons 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.
'button' of type Button. 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 button label. Set this to nothing to get action/wizard text, if defined |
| Show Label | show_label |
Show the label on the button or just the icon. |
| Icon | icon |
Button Icon |
| Stretch | stretch |
Stretch the button to fill the view contents. |
| Script | script |
Edit the button script. |
| Action | action |
Action to invoke when clicked. This is more efficient than using a script for the same puropse. |
| 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. |