---
title: "Events"
canonical: "https://docs.cuesystem.com/space/CVCHELP/508985379/Events"
format: markdown
---
> Macro (toc)

---

# Events 

An event creates a linkage between a generated event and the subsequent handling of the event. When an event is generated, an appropriate function is called or a process is started. The function of the process contains the handling program code. 

#### Syntax 1: A function as the event 

```
[Accessibility] Event Name As Function([Parameters]) [As ReturnType]
```

#### Syntax 2: A process as the event 

```
[Accessibility] Event Name As Process([Parameters])
```

If the linked process is running during the RaiseEvent action, the RaiseEvent action for that process is lost. 

#### Example 1: Driver code of a process without parameters 

```
Global GraphicClass PushButton Inherits BaseGraphicClass 
  Public Event OnPush As Process() 

  Protected Function OnUp(x As Long, y As Long, eventtime As Time, isinside As Boolean) 
    RaiseEvent OnPush() 
    // ... 
  End Function 

// ... 
End GraphicClass
```

#### Example 2: Program  code using the driver above 

```
// when the event OnPush is being raised, this process is called 

Private Process Page1_PushButton1_OnPush() Link Page1.PushButton1.OnPush 

// ... 

End Process
```

#### Example 3: Driver code of a process with a parameter 

```
Global GraphicClass ToggleButton Inherits BaseGraphicClass 
  Public Event OnToggle As Process(IsDown As Boolean) 

  Protected Function OnUp(x As Long, y As Long, eventtime As Time, isinside As Boolean) 
    // ... 
    RaiseEvent OnToggle(m_IsDown) 
    // ... 
  End Function 

// ... 
End GraphicClass
```

#### Example 4: Program  code us)ing the driver above 

```
// when the event OnToggle is being raised, this process is called 
Private Process Page1_ToggleButton1_OnToggle(IsDown As Boolean) Link Page1.ToggleButton1.OnToggle 
  // ... 
End Process
```

![image](media://4ee047a7-f95e-4a92-ab5b-8fef69208c66)

# Events with attributes 

From the IDE environment version, 8 is possible to declare process events with attributes. Process events with attributes are using cache mechanism for parameters and for calling linked processes.  

There are some parameter size limits because of memory limits in the cache mechanism.  

1. If the process has a structure type parameter, the maximum size of the structure is 20kB. This limit is checked by the XPL compiler.
2. If the process has a Text or a Bytestring parameter, the maximum size of cached parameter data is 2048 bytes. It means that only the first 1022 characters of Text or 2044 bytes of ByteString are forwarded to the linked process. This limit is not checked by the XPL compiler.

#### Syntax 3: A process as the event WithRaiseRemember 

```visualbasic
[Accessibility] Event Name As Process([Parameters]) WithRaiseRemember
```

#### Example 5: Driver code of a process with parameters and WithRaiseRemember 

```visualbasic
Global GraphicClass Slider Inherits BaseGraphicClass  
  Public Event OnValueChange As Process(actualposition as Long) WithRaiseRemember 

  Protected Function OnMove( … ) 
    // ... 
    RaiseEvent OnValueChange (actualposition) 
    // ... 
  End Function 

  // ... 
End GraphicClass
```

Event declared this way remembers the last RaiseEvent action. It means, that the process is called even if it is running at the time of the RaiseEvent action. 

![image](media://1d383415-7650-4c5b-9327-569bb27fb9d3)

#### Syntax 4: A process as the event WithFeedbackRefresh 

```visualbasic
[Accessibility] Event Name As Process([Parameters]) WithFeedbackRefresh
```

#### Example 6: Driver code of a process with parameters and WithFeedbackRefresh 

```visualbasic
Global DeviceClass Thermometter 
  Var ActualTemp As Long := 0 
  Public Event OnValueChange As Process(actualtemperature as Long) WithFeedbackRefresh 

  Function Init() 
    MeasureTemperature() 
  End Function 

  Protected Function MeasureTemperature() 
    // ... 
    Temp As Long := Measure() 
    If Temp <> ActualTemp then 
      ActualTemp := Temp 
      RaiseEvent OnValueChange (ActualTemp) 
    End If 
    // ... 
  End Function 

// ... 
End DeviceClass
```

The event declared that way remembers the last RaiseEvent action and the linked Process is automatically called when the application starts. That is ideal for driver status events. 

![image](media://b2d49bd2-047b-40dc-82bf-e5421c635beb)