Adding Debug Windows
Adding Debug Windows
The Framework provides a number of useful debugging features. This example explores the use of the Spy window. The Spy window is a window that can be activated to display events and actions as they are seen. To launch the Spy window, we could add a menu item to our main application window menu with a label “Spy Window” and a tag “Spy_Open”. The label could, in fact, be anything, but the tag is important. This value is recognized by pGetAction. In the event/action mapping used by pGetAction, this tag, when associated with a menu item, has a predefined callback. A callback is a Zim command that pGetAction executes for you. In this case, the callback is pSpy(“OPEN”) that calls a program called pSpy in the Framework. The “OPEN” parameter tells pSpy to open the spy window. When an event has an associated callback, pGetAction executes the callback for you and then waits for the next user interface event. The event with the callback is never returned to the calling program. In summary, we created a menu item with the tag “Spy_Open”. The rest is handled by pGetAction.
Once this window is open, you see each event and action as it occurs. When the application terminates, it is necessary to also close the spy window. This is done by adding the following lines to the main event loop program.
[20.1] pSpy (“CLOSE”)
This closes the spy window if it is open. This call can still be made if the spy window was not open.