---
title: "ToggleButton (Generic)"
canonical: "https://docs.cuesystem.com/space/CVCGC/419921921/ToggleButton%20(Generic)"
format: markdown
---
> Macro (toc)

---

# Description

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

# Properties

See section [https://cue.atlassian.net/wiki/spaces/CVCGC/pages/417234965/GenericButtons#Common-Properties](https://cue.atlassian.net/wiki/spaces/CVCGC/pages/417234965/GenericButtons#Common-Properties). In addition, this object uses the following properties.

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| Property Name | Data Type | Allowed Values | Default Value | Description |
| Behavior |
| DefaultState | Boolean | Down  
Up | Up | Default state of the button. |
| EventType | Long | 0 = OnDown  
1 = OnUp | 0 = OnDown | Selects whether OnToggle event is generated when button is pressed (OnDown) or released (OnUp). |

# Functions

See section [https://cue.atlassian.net/wiki/spaces/CVCGC/pages/417234965/GenericButtons#Common-Functions](https://cue.atlassian.net/wiki/spaces/CVCGC/pages/417234965/GenericButtons#Common-Functions). In addition, this object uses the following properties.

## SetEventType

This function sets EventType to neweventtype value. Possible values are

- 0 = OnDown
- 1 = OnUp

Function returns True on success or False if an error occurs (parameter is out of limits).

#### Syntax

```visualbasic
Function SetEventType(neweventtype As Long) As Boolean
```

## GetEventType

This function returns the current EventType of the button. For possible values see function SetEventType.

#### Syntax

```visualbasic
Function GetEventType() As Long
```

## SetStateDown

This function sets a button to State Down. Function returns True.

#### Syntax

```visualbasic
Function SetStateDown() As Boolean
```

## SetStateUp

This function sets a button to State Up. Function returns True.

#### Syntax

```visualbasic
Function SetStateUp() As Boolean
```

## IsStateDown

This function returns True if the button is in State Down or False if the button is in State Up.

#### Syntax

```visualbasic
Function IsStateDown() As Boolean
```

# Events

## OnToggle

This events is generated when a button is pressed or released (depends on EventType property value). If state is changed to State Down, pressed parameter is True, otherwise pressed is False.

#### Syntax

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