About events for windows and controls

Windows have several events, including Open, which is triggered when the window is opened (before it is displayed), and Close, which is triggered when the window is closed. For example, you might connect to a database and initialize some values in the window's Open event, and disconnect from a database in the Close event.

Each type of control also has its own set of events. A button, for example, has a Clicked event, which triggers when a user clicks the button. SingleLineEdits and MultiLineEdits have Modified events, which trigger when the contents of the edit control change.

Defining your own events

You can also define your own events, called user events, for a window or control, then use the EVENT keyword to trigger your user event.

For example, suppose that you offer the user several ways to update the database from a window, such as clicking a button or selecting a menu item. When the user closes the window, you want to update the database as well (after asking for confirmation). You want the same type of processing to occur after different system events.

You can define a user event for the window, write a script for that event, and then everywhere you want that event triggered, use the EVENT keyword.

To learn how to use user events, see Chapter 8, “Working with User Events.”