in reply to Tk! (entrycget w/ 'active')
I think that Tk's Clone implementation causes problems here. Every menu in Tk has one or more clones which spring off in various situations, e.g. if using the tearoff feature or probably also when simply popping up the menu.
So you need to bind and operate on clones, too. Here's a hack which seems to work:
You need Tk804.028, MasterMenu is not available before. Or just look into Tk/Menu.pm for the MasterMenu implementation, it's pure perl.... my $clone; $MW->Walk(sub { if ($_[0]->isa("Tk::Menu") && $_[0]->Master +Menu eq $MM->menu) { $clone = $_[0] }}); $clone -> bind("<Key-F1>"=> \&printentry); ... sub printentry { my $menu = shift; warn $menu->index('active'); }
Alternatively you can create a class binding for F1, so it would apply to all menus and no fiddling with clones is necessary. Note that you have to use the supplied argument to get to the right menu in the bindings' callbacks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Tk! (entrycget w/ 'active')
by halfcountplus (Hermit) on Mar 09, 2008 at 15:40 UTC | |
by eserte (Deacon) on Mar 10, 2008 at 23:02 UTC |
In Section
Seekers of Perl Wisdom