lang • eventdecl

Events declaration

EVENT Name ( [ Parameter #1 [ , Parameter #2 ... ] )

This declares a class event. This event is raised by using the RAISE keyword.

The RAISE keyword may return a boolean value to indicate if the event handler wants to cancel the event.

Examples

Event BeforeSend(Data As String)

...

Dim bResult As Boolean

' Raises the event

bResult = Raise BeforeSend("MyData")

If bResult Then
  Print "Canceled !"
Endif

Event Handler

By default, Name_EventName is the name of the method called in the event listener when an event is raised.

For example, if you have a class called FancyButton and you throw an event called FancyClick, and if in your form called FMain you have a FancyButton object named MyButton, the event handler method would look like this:

PUBLIC SUB MyButton_FancyClick(...)

The default behavior can be changed somewhat: see Object.Attach and other methods of the static Object class, as well as control groups whose information is applicable to any event-raising class.

See also