The event framework permits script writers to respond to events that happen inside an applet.
![]() |
An event listener is a mapping between an event and a handler to execute when this
event occurs.
The listeners table is a Map with events as keys and methods as values (duplicate keys are
however allowed).
diputab has only one type of listeners, the "selected" listeners.
A listener will remove himself from the listeners map after he has responded to an event he listened for but before he has executed the handler.
The design rationale for this behavior is that most handlers are single shot and that it would be to cumbersome to force the programmer to remove every listener after it was being used.
You can re-register a listener during the execution of his handler, effectively removing the single shot behavior, or use permanent listeners.
If you prefix the key of the handler in the listeners table with two plus signs "++", then the listener will not remove its self from the listeners table.
selected is the listeners map that listens for mouse click events on tabs.
If both internal and external event handlers are defined, then the external event handlers have precedence over internal event handlers. This rule makes it easy to provide for 'fall through' event handling, when external handlers are not available.
Internal handlers are predefined in diputab. There is no external intervention necessary to execute this handlers. The applet just invokes the method with the parameters defined in the internal handler record.
These type of handlers are ALWAYS possible, because the applet takes care of them. So you can always count on them to occur.
In scripting you saw how the applet's methods could be invoked from scripting languages. Now we'll see how the applet can invoke script methods through external handlers.
Think of them as call back function from the applet back to the script.
There are some conditions that must be met before external handlers can take place.