disclaimer: Without looking into the Tk source m'self...
What the line $viewer->bind("<3>", [\&post_popup_menu]) does is call the method 'bind' in (whatever class "ref $viewer" tells you) with the parameter list: ($viewer, "<3>", $arrayref). That $arrayref is the new array reference created by the [ ] operator, which in turn contains only the CODE ref (created by the \& operator(s?) ) to post_popup_menu.
Note that a CODE ref cannot have arguments associated with it; the arguments are provided by the (eventual) caller. (If you wanted to pass certain args, you could use a closure to wrap the callback, e.g. [ sub { &some_function ($whatever, @_); } ])
When your callback function (post_popup_menu) is called, it looks like it receives a parameter telling it 'who called,' which from what you said here, would be $viewer. (the 'shift' pulls the next - or in this case, first - argument to the subroutine off @_.) This object then appears to have stored the X and Y location of the event for which you were called - in this example, "<3>", a right-click (mouse button 3 click; could be on the left ;-) ).
I'd assume, then, that $viewer_menu is the menu, and to "Post" it means to "stick it" at the X,Y coords given.
Those Data::Dumper outputs should be interesting; you might want to poke around the XEvent structure to see what else you can do this way.
In reply to Re: How do Tk popup menus actually work?
by baku
in thread How do Tk popup menus actually work?
by Falkkin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |