#!c:\perl\bin\perl.exe use strict; use warnings; use Tk; use Tk::JComboBox; use Tk::Dialog; my $form; my %choices = ( 'a'=>1, 'b'=>2, 'c'=>3 ); my $selected = "a"; CreateMainForm(); MainLoop(); exit; sub CreateMainForm { $form = MainWindow->new(); $form->title("Test for JComboBox Problem"); my $testbox1 = $form->JComboBox(-textvariable=>\$selected,-validate=>'match',-mode=>'editable',-relief=>'sunken',-highlightthickness=>0); for my $x(keys %choices) { $testbox1->addItem("$x"); } $testbox1->pack(-side=>'left'); my $button = $form->Button(-text=>"Dialog",-command=>sub{CallDialog($testbox1)})->pack(-side=>'right'); return; } sub CallDialog { my $otherbox = shift; $otherbox->configure(-state=>'disabled'); my $dialog = $form->Dialog(-title=>"Part2 of test",-buttons=>["Submit","Cancel"],-default_button=>"Submit"); my $testbox2 = $dialog->JComboBox(-textvariable=>\$selected,-validate=>'match',-mode=>'editable',-relief=>'sunken',-highlightthickness=>0); for my $x(keys %choices) { $testbox2->addItem("$x"); } $testbox2->pack(-side=>'left'); my $retval = $dialog->Show(-popover=>$form,-overanchor=>'c',-popanchor=>'c',-global); if($retval eq "Cancel") { $otherbox->configure(-state=>'normal'); return; } elsif($retval eq "Submit") { $otherbox->configure(-state=>'normal'); #SaveConfig(); return; } else { #should never happen return; } }