You now know enough to be able to create new classes of window which can display arbitrary graphics, but to be able to create interactive windows you need to be able to receive events. The CAPI supports this through the use of an input model, which is a mapping of events to the callbacks that should be run when they occur.
When the event callback is called, it gets passed the
integer coordinates of the mouse pointer at the time of the event. A few events also pass additional information as necessary; for example, keyboard events also pass the key that was pressed.
For example, we can create a very simple drawing pane by adding a callback to draw a point whenever the left button is dragged across the pane. This is done as follows:
:input-model '(((:motion :button-1)
Figure 11.3 An interactive output pane
The input model above seems quite complicated, but it is just a list of event to callback mappings, where each one of these mappings is a list containing an event specification and a callback. An event specification is also a list containing keywords specifying the type of event required.
There is an example input model in
See the manual page for
LispWorks CAPI Reference Manual
for the full