Events

Introduction

Events alert applications when there is a change of state. Events occur when a user action takes place (such as a mouse click), when an attribute value is changed, or when a user-defined condition occurs. Event handlers then provide a response to the change.
Use the Class Editor to create events that are specific to an entire class. Use the Properties window to create events that are specific to a single object.
SAS/AF software supports system events, which can include user interface events (such as mouse clicks) as well as “attribute changed” events that occur when an attribute value is updated. For system events, the State metadata item is 'S'. In order for “attribute changed” events to be sent automatically, the component must have the SendEvent metadata item for the attribute set to 'Yes'. See Enabling Attribute Linking for details.
SAS/AF software also supports user-defined events, which can be registered to specific classes as needed and are inherited by subclasses.

Event Metadata

Events are implemented and maintained with metadata. You can query a class (or an event within a class) to view the event metadata, and you can create your own metadata list to add or change an event. For example, to list the metadata for the click event, execute code similar to the following:
init:
   dcl num rc;
   dcl list metadata;
   dcl object obj;

   obj=loadclass('sashelp.classes.listbox_c.class');

   rc=obj._getEvent('click',metadata);
   call putlist(metadata,'',3);
return;
The following event metadata is returned:
(NAME='click'
 STATE='S'
 DESCRIPTION='Occurs on a click'
 CLASS=4415
 EXECUTE='System'
 METHOD=''
 ENABLED='Yes'
 CLASS=4415
 )
The event metadata list contains the following named items:
Name
is the name of the event. Event names may be up to 256 characters long.
State
is the current state of each event. Valid values are I | N | S (corresponding to Inherited, New, or System). This is a read-only metadata item.
Execute
describes how the event is sent. Events can be sent automatically either before or after a method. They can also be programmed manually with SCL. Valid values are: A | B | M (corresponding to After, Before, Manual). New events default to 'After'.
The Class Editor and the Properties window display Execute metadata in the Send column of the table.
Method
is the name of the method that triggers the event (if Execute=A | B). A method name must be specified for new events if they are to be sent automatically. The field remains blank if the event is sent manually (if Execute=M).
Enabled
indicates whether an event is enabled or disabled. Valid values are Y | N.
Description
is a descriptive summary of the event's purpose. For inherited and system events, the description is forwarded from the parent class. The maximum length is 256 characters.