Falkkin has asked for the wisdom of the Perl Monks concerning the following question:
There doesn't seem to be any built-in support (i.e. a specific module) for creating these -- I had to look through the Tk source distribution to find what I wanted. I basically copied their code verbatim, and it works, but relies on some sort of magic I don't understand. Here's the relevant snippet:
The line that mystifies me is the first line of post_popup_menu... I'm not sending the callback any arguments, but it still manages to receive a mysterious $w variable somehow. After doing some preliminary poking with Data::Dumper, it looks like $w is the $viewer that the menu is associated with.# A right-click in the viewer should bring up the popup menu. $viewer->bind("<3>", [\&post_popup_menu]); sub post_popup_menu { my $w = shift; # no idea how this works. my $X = $w->XEvent->X; my $Y = $w->XEvent->Y; $viewer_menu->Post($X, $Y); }
Beyond that, however, I'm stumped... anyone know how Tk works this magic?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do Tk popup menus actually work?
by chipmunk (Parson) on Feb 06, 2001 at 21:42 UTC | |
|
Re: How do Tk popup menus actually work?
by kschwab (Vicar) on Feb 06, 2001 at 21:35 UTC | |
|
Re: How do Tk popup menus actually work?
by baku (Scribe) on Feb 06, 2001 at 21:45 UTC | |
|
Re: How do Tk popup menus actually work?
by ichimunki (Priest) on Feb 07, 2001 at 00:52 UTC | |
|
Re: How do Tk popup menus actually work?
by azatoth (Curate) on Feb 06, 2001 at 21:28 UTC |