Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Option menu callbacks

by dimmesdale (Friar)
on Jul 23, 2002 at 13:17 UTC ( [id://184393] : perlquestion . print w/replies, xml ) Need Help??

dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:

I'm having trouble creating the correct procedure for some Tk::Optionmenus. There are two of them: one represents a list of subdirectories, the other represents a list of files. When a user changes the subdirectory optionmenu I want to change the file optionmenu to reflect said change.

I'm getting some problems, however, as I said. I'm creating several of these on a NoteBook interface, and it seems that on tabs after the first, the callbacks don't function correctly if I change the file optionmenu first.

Well... actually that was yesterday. Today the code isn't even working. I've done some debugging and it seems that the callback is getting an undefined (undef) value. So I tried the Ev( ... ) construct, but it's still undefined.

Here's the code that I have for the two optionmenu's:

my $fom = $page->[$_-1]->Optionmenu( -variable => \$info->{file}->[$_-1], -options => get_files($info->{subdir}->[$_-1]), ); my $dom = $page->[$_-1]->Optionmenu( -variable => \$info->{subdir}->[$_-1], -options => [@subdirs], -command => sub { $fom->configure(-options => get_fil +es($_[0]->{base},$info->{subdir}->[$_-1])) }, );

What should I do to get the right value into the -command sub line?