An interactor is needed here because the view only receives mouse-down events when the mouse is clicked in the view, and you want to know when the mouse is clicked outside the view so that you can stop the polygon.
This example is for illustration only. You might want to use the Tools framework or similar interactors provided by GrafEdit to accomplish this functionality in a real program.
The KeyInteractors sample also illustrates use of interactors, except with key events.
TPolygonInteractor is defined in PolygonInteractor.h and PolygonInteractor.C. It derives from TInteractor for interactor protocol, and MMouseEventHandler so that it can handle events. It calls SetCoordinateView in its constructor so that events are sent to it in that view's coordinate system. As it receives mouse down events, it adds points to the list of points it maintains, and then creates a graphic from this list, which the view then adopts and displays.
This means, however, that your view must keep a reference to the interactor while the interactor exists, in order to inform it when the view activates and deactivates. In this example, the interactor maintains this reference, calling the methods AddInteractor and RemoveInteractor to set your view's reference to the interactor when it is created, and clear your view's reference to it when it is destroyed. Your view overrides HandleDeactivate to stop the interactor when there is one. This is essentially the same mechanism used in KeyInteractors.
It is not sufficient for HandleDeactivate to merely deactivate the interactor. This would cause it to stop dispatching events to itself, but also block the device from dispatching events to the view. Instead, you call SetDone(TRUE) on the interactor, and the next time the device tries to send the event to the interactor, it will delete it and then dispatch the event normally, which is what you want.
When the mouse is clicked in any view that does share the same event receiver, the interactor is called. The window itself is one such view, so the interactor can be called when the mouse is clicked in the title bar. To allow the window to handle this click, the interactor must 1) call SetDone(true) to tell the device it is finished and must be deleted, and 2) return false from MouseButtonDown to tell the device to continue dispatching the event. The window then receives the event and handles it as usual.