next up previous index
Next: A Simple Example Up: Prolog as the Previous: Handling Tk Events

System Event Handling

We have already explained in Section 3.6 how the Tk event mechanism works. When Tk is connected to Prolog and a Prolog predicate is executing or when it blocks, no Tk events are handled and thus no user interaction with the GUI is possible. To avoid this problem at least partially, the ECLiPSe top-level loop is customised when the interactive tk/1     predicate is called. The ECLiPSe event handler for the event 153 (toplevel prompt) event! ECLiPSe !153 is modified so that when the prompt is printed, the system is waiting both for user input and for Tk events. If a Tk event occurs which is handled by Tk itself, it is processed normally. If a Prolog graphics event occurs, the ECLiPSe event 333 is raised, which by default   prints a warning. Its event handler can be redefined e.g. to handle Prolog graphics events even if the application is not active (but its display is). If the user types something to the Prolog top-level, it is   normally executed. The Prolog top-level thus behaves quite naturally.

When Tk exits, it raises the Prolog graphics event ["exit"].   If this event is handled by the Prolog top-level loop, it raises the ECLiPSe event 333 and if no user   event handler is defined for this event, you might see the warning

[eclipse 14]: warning: window event in ["exit"]
when Tk exits. This is not an error, it simply tells the user that a Prolog graphics event occurred while the Prolog top-level was in charge.



next up previous index
Next: A Simple Example Up: Prolog as the Previous: Handling Tk Events



Micha Meier
Tue Jul 2 09:49:39 MET DST 1996