in reply to How do Tk popup menus actually work?

You're not calling the callback at all; you're just passing a reference to the callback to $viewer->bind(). When $viewer calls the callback later in the execution, it includes itself as an argument. This is just a way for your callback to get access to the information it needs from its parent widget, in this case the X and Y coordinates of the event.

Of course, one must know what arguments a callback will be called with, in order to write the callback properly. See HTML::Parser for an example of a well-documented callback interface.

  • Comment on Re: How do Tk popup menus actually work?