Hello
I'm trying to add to a Tk pop-up menu a list of options using an array.
sub add_edit_popup { my ($mw, $obj) = @_; my $menu = $mw->Menu(-tearoff=>0, -menuitems=>[ [command=>'Start Term Info', -command=>[\&get_term_info_from_col_1 +_partial, $obj,]], '', [qw/command Copy/, -command=>['clipboardCopy', $obj,]], [qw/command Paste/, -command=>['clipboardPaste', $obj]], '', [command=>'Select All', -command=>[ sub { $_[0]->selectionRange(0, 'end'); }, $obj, ]], [command=>'Unselect All', -command=>[ sub { $_[0]->selectionClear; }, $obj, ]], '', [ Cascade => 'Insert symbol', -tearoff => 0, -menuitems => [ foreach my $symbol (@list_symbols) { [command => "$symbol",-command => sub{inser +t_symbol($symbol)}]; } ], ], ]); $obj->menu($menu); $obj->bind('<3>', ['PostPopupMenu', Ev('X'), Ev('Y'), ]); return $obj; }
I'm encountering problem with the foreach loop, which works fine in a normal menu widget. Waht is wrong with it?
In reply to tk popup menu foreach by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |