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
Last Edited by: Wyatt, October 26, 1983 4:29 pm
DIRECTORY
ViewerClasses USING [Viewer];
ViewerEvents: CEDAR DEFINITIONS
= 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, a ViewerFlavor, a ViewerClass, or NIL. When before is TRUE the EventProc can abort the event. A client that wishes to unregister the procedure at some point should save the EventRegistration returned. Note: many of the EventProcs are called from within the Viewer tree write lock. If you try to perform a ViewerOps function that requires the write lock from within your EventProc then you will deadlock. Some of the events may also 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 to avoid degrading 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.