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

---

# Description

This button behaves like a simple push button and enables users to distinguish between short and long presses. The time boundary between short and long press is defined by the property LongPressTime. It has only two states - State Up and State Down. The button is in State Down when it is pushed, otherwise, it is in State Up. The button generates OnPress event when it is pressed. The parameter of the event delivers information if a short or long press was done.

![image](media://8cdafff1-1236-4146-8bf8-243ae646d924)

# 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 |
| LongPressTime | Time | Any non-negative | 0:0.4 | Time boundary between short and long press. |

# 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.

## IsButtonPressed

By this function, you can test whether a button is pushed (function returns True) or not (return value is False).

#### Syntax

```visualbasic
Function IsButtonPressed() As Boolean
```

## SetLongPressTime

This function sets the LongPressTime of the button. The function returns True on success or False if an error occurs (i.e. newlongpresstime < :.0).

#### Syntax

```visualbasic
Function SetLongPressTime(newlongpresstime As Time) As Boolean
```

## GetLongPressTime

This function returns the current LongPressTime.

#### Syntax

```visualbasic
Function GetLongPressTime() As Time
```

## WaitWhilePressed

This function waits for the end of the button push. If an optional timeout parameter is used, the maximum waiting time is limited by timeout value. In case of timeout excess, the function returns False, otherwise it returns True.

#### Syntax

```visualbasic
Function WaitWhilePressed(Optional timeout As Time := _TIME_INFINITE) As Boolean
```

# Events

## OnPress 

This event is generated when the button is released (in case that press is shorter then LongPressTime) or after LongPressTime from the start of pushing the button (in case that press is longer then LongPressTime). If press of the button is longer than LongPressTime, longpress parameter is True, otherwise longpress is False.

#### Syntax

```visualbasic
Event OnPress As Process(longpress As Boolean)
```