Switch
The switch writes on or off to a Bool tag on an operator click. The look is a toggle with a knob, a button or a check box; on and off texts and colors are your own. “Confirmation” asks a question before switching, the element right and the user’s rights are checked, and the Value change event fires after the write.
Properties
Section titled “Properties”Besides the properties of every element — name, position, size, tooltip, rotation, transparency and the operate right:
| Property | Values | Default | Description |
|---|---|---|---|
Style |
Toggle, Button, CheckBox |
Toggle |
View |
Tag |
tag name | Tag | |
OnText |
text | Вкл |
“On” text |
OffText |
text | Выкл |
“Off” text |
OnColor |
#RRGGBB |
#3D4A55 |
“On” color |
Confirm |
text | Confirmation. Question before switching; empty — no question | |
OffColor |
#RRGGBB |
#9AA3AB |
“Off” color |
KnobColor |
#RRGGBB |
#FFFFFF |
Thumb color. For «Toggle» style |
OnForeground |
#RRGGBB |
“On” text color. For «Button» style; empty — white | |
FontFamily |
text | Font. Windows font name: Segoe UI, Arial, Consolas, Tahoma; empty — default | |
FontSize |
number | 14 |
Font size |
Bold |
true / false |
false |
Bold |
Italic |
true / false |
false |
Italic |
Underline |
true / false |
false |
Underlined |
Foreground |
#RRGGBB |
Text color. Empty — default | |
Alignment |
Left, Center, Right |
Left |
Alignment |
VerticalAlignment |
Top, Center, Bottom |
Center |
Vertically |
Background |
#RRGGBB |
Background. Empty — default | |
BackgroundStyle |
Solid, VerticalGradient, HorizontalGradient, Transparent |
Solid |
Background fill. Solid, gradient (3D) or transparent |
Background2 |
#RRGGBB |
Second background color. For gradient; empty — lighter than background | |
BorderColor |
#RRGGBB |
Border color. Empty — default | |
BorderWidth |
number | 0 |
Border width. 0 — no border |
BorderStyle |
Solid, Dash, Dot, DashDot |
Solid |
Border style |
CornerRadius |
number | 0 |
Corner radius |
Padding |
number | Padding. From border to text; empty — default | |
Shadow |
true / false |
false |
Shadow |
FlashBackground |
true / false |
false |
Flash background. Background alternates with the flash color; to switch by tag — use property animation |
FlashBackgroundColor |
#RRGGBB |
#D32F2F |
Background flash color |
FlashForeground |
true / false |
false |
Flash text |
FlashForegroundColor |
#RRGGBB |
#FFFFFF |
Text flash color |
FlashRate |
Slow, Medium, Fast |
Medium |
Flash rate |
From scripts
Section titled “From scripts”Item.Type = Switch. Any property is read and changed by name: Item.OnColor = "#D32F2F". The common element members (Visible, Enabled, Value, Raise, Apply…) are described in Elements from scripts.
Actions of this element:
| Member | Description |
|---|---|
IsOn |
Whether it is on; null — no value |
Toggle() |
Toggle like an operator click (confirmation, rights, event) |
Switch(on) |
Turn on (true) or off (false) as the operator would |
Events
Section titled “Events”Mouse, hover, focus and keyboard — as for any element (see Events and functions). Its own events:
- Value change (
Change) — The operator entered a new value.
Examples
Section titled “Examples”Toggle as the operator does — with the question and the right check.
Screen.Items("Lighting").Toggle();Turn off all heaters of an area with an “Area stop” button.
["Heater1", "Heater2", "Heater3"].forEach(function (name) { var s = Screen.Items(name); if (s.IsOn) s.Switch(false);});Write without a question — straight to the tag, when the script has checked everything itself.
Screen.Items("Lighting").Value = false;