Ok... this event-driven stuff is a complete nightmare, I can now see that line 231 sets this up correctly.  Spaghetti for all!