Esteemed monks,
I'm trying to have a Perl/Tk application create menus on the fly, depending on current state. This works... mostly. When I exit the application, I get an error message along the following lines:
18e6748 is not a hash at C:/Perl/site/lib/Tk.pm line 340.
This application has requested the Runtime to terminate it in an unusu
+al way.
Please contact the application's support team for more information.
I've been able to reproduce this with a minimalist example:
#!/usr/bin/perl
use Tk;
my $mw = MainWindow->new;
my $txt = $mw->Text()->pack(-side => 'top');
my $number = 1;
my $letter = 'a';
my $popup_menu = "";
my $new_menu = $mw->Menu();
$new_menu->add('command',
-label => "Click me to show the pop-up menu.",
-command => sub {
$popup_menu = $mw->Menu();
$popup_menu->add('command',
-label => "Number: $number",
-command => sub {
print STDERR "Number: $number\n";
$number++;
}
);
$popup_menu->add('command',
-label => "Letter: $letter",
-command => sub {
print STDERR "Letter: $letter\n";
$letter++;
}
);
$popup_menu->Popup(qw/-popover cursor/);
}
);
$txt->menu( $new_menu );
MainLoop;
Doing a SuperSearch for keywords "application requested Runtime terminate unusual" didn't turn up anything.
I'm sure I am not understanding some fundamental Tk concept here... can anyone point me in the right direction?