Switch
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
| Setting | Type | Default | Description |
|---|---|---|---|
On ValueonValue | Value (typed) | true | Value written when Toggle/Switch is ON. |
Off ValueoffValue | Value (typed) | false | Value written when Toggle/Switch is OFF. |
Process ValueprocessValue | Value (typed) | true | Base read/write value. When State Mode is Process Value, the visual state is computed from this value. |
Behavior
| Setting | Type | Default | Description |
|---|---|---|---|
Read OnlyreadOnly | Checkbox | Off | When on, the user cannot change the value at runtime. |
Lock ReasonlockReason | 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 ConfirmationneedsConfirmation | Checkbox | Off | Asks for confirmation before the value is written to the Tag. |
Labels / Icons
| Setting | Type | Default | Description |
|---|---|---|---|
On LabelonLabel | Text | ON | Text shown on the switch when it is on. The font size adapts to the longer label. |
Off LabeloffLabel | Text | OFF | Text shown on the switch when it is off. The font size adapts to the longer label. |
Appearance
| Setting | Type | Default | Description |
|---|---|---|---|
Input ClassinputClass | CSS classes | — | CSS classes added to the switch element. |
Knob ColorknobColor | 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 ColorknobOffColor | 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
| Setting | Type | Default | Description |
|---|---|---|---|
Enable FlashingenableFlashing | Checkbox | Off | Makes the widget blink (an opacity pulse every second). Usually bound to an alarm condition. |
Log ButtonlogButton | Checkbox | Off | At 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.