ViewerEvents.mesa; Written by S. McGregor
Edited by McGregor on July 21, 1983 10:45 am
Last Edited by: Maxwell, January 11, 1983 12:26 pm
DIRECTORY
ViewerClasses USING [Viewer];
ViewerEvents: CEDAR DEFINITIONS IMPORTS ViewerClasses = BEGIN
EventProc: TYPE = PROC [viewer: ViewerClasses.Viewer, event: ViewerEvent, before: BOOL]
RETURNS[abort: BOOLFALSE] ;
abort will abort the event and the remaining EventProcs
This interface, while fairly easy to use, requires some understanding of the viewer tree and paint locking mechanisms. All of the calls to client code occur outside of the locking mechanism. To be absolutely safe, the client should lock the appropriate resources and retest the initial condition. Consult a Viewer's wizard for more information.
ViewerEvent: TYPE =
{save, edit, destroy, create, close, open, grow, changeColumn, setInputFocus, killInputFocus} ;
There are two calls for each event: before anything happens and after everything (including the painting) is complete. The first call of a create occurs after the ViewerRec is NEW'ed but before the parameters are checked. Parameters can be changed if desired.
EventRegistration: TYPE = REF ;
RegisterEventProc: PROC [proc: EventProc, event: ViewerEvent,
filter: REF ANYNIL, before: BOOLTRUE] RETURNS [EventRegistration] ;
Register a procedure that can be called before or after the specified event occurs. The filter can be a particular viewer, the atom for a class, or NIL. When before is TRUE the EventProc can abort the event. If the client wishes to unregister the procedure at some point, they should save the EventRegistration returned. N.B. - many of the EventProcs are called from within the Viewer tree write lock. If you attempt to perform a ViewerOps function that requires the write lock from within your EventProc then you will deadlock. Some of the events may additionally have acquired the paint lock. If you are concerned about deadlocks or if you plan to do anything time-consuming in an EventProc, consider forking a separate process so as not to adversely affect system performance.
UnRegisterEventProc: PROC [proc: EventRegistration, event: ViewerEvent] ;
Unregister an EventProc registered via RegisterEventProc.
ProcessEvent: PRIVATE PROC [event: ViewerEvent, viewer: ViewerClasses.Viewer, before: BOOL]
RETURNS[abort: BOOL] ;
Window manager internal use only. Called once before and once after each event.
END.