space
Previous Page | Next Page

SAS Object-Oriented Programming Concepts

Event Handlers

An event handler is a property that determines which method to execute after an event occurs. Essentially, an event handler is a method that executes another method after an event is received. Use the Class Editor to create event handlers that are specific to an entire class. Use the Properties window to create event handlers that are specific to a single object.


Event Handler Metadata

SAS/AF software uses a set of event handler metadata to implement and maintain event handlers. This metadata exists as a list that is stored with the class. You can query a class (or an event handler within a class) to view the event handler metadata. You can also create your own metadata list to add or change an event handler. For example, to list the metadata for a particular event handler, 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._getEventHandler('_self_','click',
                           '_onClick',metadata);
   call putlist(metadata,'',3);
 return;

The following event handler metadata is returned:

(SENDER='_self_'
 EVENT='visible changed'
 DESCRIPTION='Refresh myself'
 STATE='N'
 METHOD='_refresh'
 ENABLED='Yes'
 )

The metadata contains the following named items:

State

is the current state of each event handler. Values include Inherited, New, or System, which are represented by I, N, and S, respectively.

Sender

is the name of the object that generates the event. The default value is _self_. Valid values are _self_, any object (*), or the name of a component on the frame.

Event

is the name of the event that is being handled.

Method

is the name of the method to execute when the event is sent.

Enabled

shows whether an event handler is enabled or disabled. Valid values are Y | N.

System events (State=S) are always enabled.

Description

is text that describes the event handler. The maximum length is 256 characters.

space
Previous Page | Next Page | Top of Page