in reply to How do Tk popup menus actually work?

Why were you looking through Tk source? :)

perldoc Tk::Menu and perldoc Tk::Bind get you most of the way to the above.

$w is simply the container in which the event happened being shifted off the callback parameters, which you are then running the XEvent method on to get the location of the right-click.

The argument that gets shifted to $w is an inherent argument, due to object oriented nature of Tk.
  • Comment on Re: How do Tk popup menus actually work?