Creating an Event Handler

Task

Assumed we have a sequence of objects not fitting onto one page. The sequence is broken by the layout algorithm and than continued on a new page. What we want to have is a short note at the end of the sequences first part like "to be continued".

Writing an Eventhandler

This is a typical task for an eventhandler. The following example code defines a simple handler which does exactly the job requested above:

eventhandler sequenceHandler() {
	event BROKEN {
		
	}
}

This is done very easily: a new eventhandler is defined within the DCL scripts loaded; then the event which has to processed (BROKEN) and something to do in response to the event (adding text string "to be continued ...") are specified.

Activating the Event Handler

Now we have an event handler, but we still need to specify which design patterns have to use it.

design sequence() {
	pattern first:
		...
		handler = sequenceHandler();
	{
		...
	}
}

To do this means just adding a reference to all design command(s) which should be affected by a given handler, here a command called sequence. Each time a sequence is broken, the handler will be called and add "to be continued ..." to the sequence.