RaiseEvent

From Xojo Documentation

Language Keyword

Used on a class to call the implementation of an event definition on a subclass.

Usage

RaiseEvent EventName [(parameters)]

Part Type Description
EventName The name of the event that you want to trigger.
Parameters Parameters to EventName, if any.

Notes

EventName is the name of the event that you want to call. If the event requires parameters, then they are passed as the optional parameter to RaiseEvent. RaiseEvent is useful when you have an Event Definition that has the same name as a method and the ordinary way to call an event definition is ambiguous.

The only place you can use RaiseEvent is in the class definition where you added the Event Definition. In particular, you cannot raise an event from an instance of the class on the window, nor can you raise the event from outside the class. If you want to arbitrarily call an event, you will need to create a supporting method within the class as well that raises the event.

fa-info-circle-32.png
If the actual event is not implemented on the subclass, then nothing gets called.

Sample Code

// MyEvent is an Event Definition on the class
RaiseEvent MyEvent

// MyTestEvent is an Event Definition with String and Integer parameters
RaiseEvent MyTestEvent("Hello", 42)

// For an event that returns a value you can call it like this
Var value As Integer
value = RaiseEvent MyReturnEvent("Hello")

// RaiseEvent is optional, so you can also call the event by using its name
MyEvent
MyTestEvent("Hello", 42)
value = MyReturnEvent("Hello")