Skip to content

Switch ​

About 3 min read

TwSwitch · Category: Buttons

Touch panels ​

When the Switch is locked, tapping it shows the Lock Reason text. With Needs Confirmation on, the confirmation dialog carries the title and the label of the state it moves to, for example "Pump 1 – ON" (Confirmation). onMouseDown and onMouseUp code also runs on touch screens (Event code on touch).

Settings ​

These settings are in the properties panel on the right while the widget is selected. The default value is the value the widget has when it is first added to a page.

Value / Write ​

SettingTypeDefaultDescription
On Value
onValue
Value (typed)trueValue written when Toggle/Switch is ON.
Off Value
offValue
Value (typed)falseValue written when Toggle/Switch is OFF.
Process Value
processValue
Value (typed)trueBase read/write value. When State Mode is Process Value, the visual state is computed from this value.

Behavior ​

SettingTypeDefaultDescription
Read Only
readOnly
CheckboxOffWhen on, the user cannot change the value at runtime.
Lock Reason
lockReason
Text—Optional. While the control is locked at runtime (Read Only bound to a tag that is true, or a user without write permission), a tap shows this text briefly instead of the permission message, and it appears as the tooltip. Example: "Interlock: door open". A locale key is translated. Empty keeps the default behaviour.
Needs Confirmation
needsConfirmation
CheckboxOffAsks for confirmation before the value is written to the Tag.

Labels / Icons ​

SettingTypeDefaultDescription
On Label
onLabel
TextONText shown on the switch when it is on. The font size adapts to the longer label.
Off Label
offLabel
TextOFFText shown on the switch when it is off. The font size adapts to the longer label.

Appearance ​

SettingTypeDefaultDescription
Input Class
inputClass
CSS classes—CSS classes added to the switch element.
Knob Color
knobColor
Color—Color of the knob when the switch is on. Empty uses the off knob color, or else the foreground color (white by default).
Knob Off Color
knobOffColor
Color—Color of the knob when the switch is off. Empty uses the on knob color, or else the foreground color (white by default).

Other settings ​

SettingTypeDefaultDescription
Enable Flashing
enableFlashing
CheckboxOffMakes the widget blink (an opacity pulse every second). Usually bound to an alarm condition.
Log Button
logButton
CheckboxOffAt runtime shows a chart icon when hovering the widget; clicking it adds the Tags bound to the widget to the log Tag list.

Bindings ​

In the Bindings (Rules) section of the properties panel, a Tag can be bound to the following properties of this widget with a Direct binding. The binding types (Direct, IntRange, FloatRange, Boolean, Bit) are the same for all widgets; they are described on the Widget Reference page.

title, visible, authorization, x, y, width, height, rotation, class, foregroundColor, backgroundColor, borderColor, borderStyle, borderWidth, borderRadius, borderTopLeftRadius, borderTopRightRadius, enableFlashing, logButton, onClick, onMouseDown, onMouseUp, lockReason, processValue, readOnly, inputClass, needsConfirmation, onLabel, offLabel, onValue, offValue, knobColor, knobOffColor

The style fields of the widget can also be bound as style.<field> (e.g. style.fontSize).

Common sections ​

While this widget is selected, the properties panel also shows these common sections: General, Layout, Appearance, Events, Bindings (Rules). These sections are described on the Page Editor page.

2WinScada 2.10