1. Overview & Purpose
The neoSwitch plugin provides smooth, antialiased animated toggle switch controls (styles: fluent, ios, flat) for VisualNEO Win applications.
It supports customizable ON/OFF colors, thumb circle colors, label text with flexible placement (left, right, none), keyboard spacebar toggle, and automatic event notifications (on, off, change).
The optional bound variable is a live two-way binding, matching VisualNEO's core input controls. An empty variable is initialized from checked; user interaction updates the variable before event scripts run; and changing the variable from NeoScript updates the switch without firing a user event. Its value is always True or False.
2. Custom Control Properties
Control: neoSwitch Control (neo-switch-control)
| Property Name | Type | Default Value | Description |
|---|---|---|---|
| variable | variable | "" | Optional VisualNEO variable (e.g. [MySwitch]) bound directly to the switch state (True/False). |
checked | boolean | false | Initial ON/OFF toggle state. |
label | string | "Toggle Switch" | Descriptive text label string. |
labelPosition | string | "right" | Label text placement ("right", "left", "none"). |
style | string | "fluent" | Visual animation style ("fluent", "ios", "flat"). |
onColor | string | "#2ECC71" | Background color when active ON (#HEX). |
offColor | string | "#BDC3C7" | Background color when inactive OFF (#HEX). |
thumbColor | string | "#FFFFFF" | Sliding thumb circle color (#HEX). |
bgColor | string | "auto" | Control background color (#HEX or "auto"). |
3. Actions & Commands Reference
neoSwitchSetValue
Sets the state (True/False, 1/0, ON/OFF) of a neoSwitchControl.
- Command Syntax:
neoSwitchSetValue "ObjectName" "State"
neoSwitchGetValue
Retrieves current boolean state ("True" or "False") into [neoSwitchResult] (and optionally into a specified variable).
- Command Syntax:
neoSwitchGetValue "ObjectName" "[ResultVar]" - Parameters:
- •
ObjectName(string): Target control name. - •
ResultVar(string, optional): Destination variable (e.g."[IsActive]").
neoSwitchToggle
Inverts the switch state (ON to OFF, or OFF to ON).
- Command Syntax:
neoSwitchToggle "ObjectName"
neoSwitchSetColors
Updates active ON, inactive OFF, and thumb colors.
- Command Syntax:
neoSwitchSetColors "ObjectName" "OnColorHex" "OffColorHex" "ThumbColorHex"
neoSwitchSetLabel
Sets label text and placement ("left", "right", "none").
- Command Syntax:
neoSwitchSetLabel "ObjectName" "Text" "Placement"
4. Events Reference
on: Triggered when the switch is toggled to ON (checked: true).off: Triggered when the switch is toggled to OFF (checked: false).change: Triggered on any state toggle change.
The event payload is available in [ModernEventJSON]. For ordinary boolean logic, binding the variable property is simpler and avoids calling neoSwitchGetValue from inside an event:
. The control's variable property is [DarkModeEnabled].
. This script can be used directly in the change event.
SetVar "[StatusText]" "Dark mode: [DarkModeEnabled]"
5. Practical Usage Example (VisualNEO Win Script)
. --- Enable dark mode toggle ---
neoSwitchSetColors "Switch1" "#3B82F6" "#475569" "#FFFFFF"
neoSwitchSetLabel "Switch1" "Dark Mode" "right"
neoSwitchSetValue "Switch1" "ON"
. --- Toggle state on button click ---
neoSwitchToggle "Switch1"