Class definition files can define static visual handle-based objects (widgets) as PRIVATE data members. These built-in widgets expose a well-defined set of events that an application can respond to, by using the ON statement. The ON statement is supported in the main block of a class definition file. As noted previously, the main block cannot contain executable code. Therefore a class definition file cannot specify an ON statement within executable conditional logic, nor can it contain a WAIT-FOR statement in the main block. However, the main block can contain ON statements that respond to a specific event that occurs on a static visual object.
The following contrived code demonstrates this capability:
CLASS Disp:
/* These data members are PRIVATE by default. */
DEFINE BUTTON msg. DEFINE BUTTON done. DEFINE FRAME f msg done.
/* Unconditional ON block valid in the main block. */
ON 'choose':U OF msg MESSAGE "click" VIEW-AS ALERT-BOX.
CONSTRUCTOR PUBLIC Disp ( ):
modal_display ( ). END CONSTRUCTOR.
/* WAIT-FOR is done in a method. */
METHOD PRIVATE VOID modal_display ( ):
ENABLE ALL WITH FRAME f.
WAIT-FOR CHOOSE OF done. END METHOD.