---
title: "ToggleSwitch (Aluminum)"
canonical: "https://docs.cuesystem.com/space/CVCGC/460816423/ToggleSwitch%20(Aluminum)"
format: markdown
---
> Macro (toc)

---

# Description

This object has following stable states State On, State Off, and also State Pushed if it is pressed or moved. Each button push toggles between State On and State Off. The button generates event OnToggle. You can choose whether the event is generated when the button is pressed or when the button is released.

![image](media://8895afed-8223-4a18-a83f-cd8f759164a7)

# Properties

See [https://cue.atlassian.net/wiki/spaces/CVCGC/pages/407535672/Common+Section+of+Generic+object+collection#Properties](https://cue.atlassian.net/wiki/spaces/CVCGC/pages/407535672/Common+Section+of+Generic+object+collection#Properties). In addition this object uses following properties.

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| Property Name | Data Type | Allowed Values | Default Value | Description |
| Behavior |
| DefaultState | Boolean | On<br>Off | Off | Default state of<br>ToggleSwitch. |
| Appearance |
| ButtonStyle | Long | Rounded Corner<br>Sharp Corner | Rounded Corner | Button has rounded or<br>sharp corners. |
| OffCaption | AddressOf<br>Text | Any | txtOff | Text shown on the<br>button in State Off. |
| OnCaption | AddressOf<br>Text | Any | txtOn | Text shown on the<br>button in State On. |
| TextFont | AddressOf<br>_Font | Any | ButtonFont | OffCaption and<br>OnCaption text font. |

# Functions

See manual [https://cue.atlassian.net/wiki/spaces/CVCGC/pages/407535672/Common+Section+of+Generic+object+collection#Functions](https://cue.atlassian.net/wiki/spaces/CVCGC/pages/407535672/Common+Section+of+Generic+object+collection#Functions). In addition this object uses following functions.

## SetState

This function sets a newstate to State of ToggleSwitch. Function returns True. You can use the following predefined constants

- STATE_ON
- STATE_OFF

#### Syntax

```visualbasic
Function SetState(ison As Boolean) As Boolean
```

## GetState

This function returns State.

#### Syntax

```visualbasic
Function GetState() As Boolean
```

## SetButtonStyle

This function sets a newbuttonstyle to ButtonStyle. Function returns True. You can use the following predefined constants

- BUTTON_STYLE_ROUNDED_CORNER
- BUTTON_STYLE_SHARP_CORNER

#### Syntax

```visualbasic
Function SetButtonStyle(newbuttonstyle As Long) As Boolean
```

## GetButtonStyle

This function returns ButtonStyle.

#### Syntax

```visualbasic
Function GetButtonStyle() As Long
```

## SetOffCaption

This function sets a newoffcaption to OffCaption. Function returns True.

#### Syntax

```visualbasic
Function SetOffCaption(newoffcaption As AddressOf Text) As Boolean
```

## GetOffCaption

This function returns OffCaption.

#### Syntax

```visualbasic
Function GetOffCaption() As AddressOf Text
```

## SetOnCaption

This function sets a newoncaption to OnCaption. Function returns True.

#### Syntax

```visualbasic
Function SetOnCaption(newoncaption As AddressOf Text) As Boolean
```

## GetOnCaption

This function returns OnCaption.

#### Syntax

```visualbasic
Function GetOnCaption() As AddressOf Text
```

## SetTextFont

This function sets a newtextfont to TextFont. Function returns True.

#### Syntax

```visualbasic
Function SetTextFont(newtextfont As AddressOf _Font) As Boolean
```

## GetTextFont

This function returns OnCaption.

#### Syntax

```visualbasic
Function GetTextFont() As AddressOf _Font
```

# Events

## OnToggle 

This events is generated when a button is released. If state is changed to State On, ison parameter is True, otherwise ison is False.

#### Syntax

```visualbasic
Event OnToggle As Process (ison As Boolean)
```