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