ChrisR has asked for the wisdom of the Perl Monks concerning the following question:
I have a window for used for searching a database with widgets used for selecting a subset of criteria and one of these widgets is a JComboBox. The same window also contains a button that will bring up a dialog used to define the whole set of search criteria. The dialog also includes a JComboBox widget that is linked to the same data as the first JComboBox I mentioned.
The problem is that when I change the value of the JComboBox in the dialog, it makes the first JComboBox drop down it's list. Subsequent changes to the JComboBox in the dialog can cause more lists to be shown in various places on the screen that don't go away even when the dialog is closed. I have tried to set the first JComboBox's -state=>'disabled' before showing the dialog but that didn't help. Even though the combobox on the first window is disabled, it still pops up the list. Wow, that even confused me a little. Here is a much abbreviated example of the problem:#!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,-validat +e=>'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{CallDialo +g($testbox1)})->pack(-side=>'right'); return; } sub CallDialog { my $otherbox = shift; $otherbox->configure(-state=>'disabled'); my $dialog = $form->Dialog(-title=>"Part2 of test",-buttons=>["Sub +mit","Cancel"],-default_button=>"Submit"); my $testbox2 = $dialog->JComboBox(-textvariable=>\$selected,-valid +ate=>'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',-popan +chor=>'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; } }
Janitored by Arunbear - added readmore tags, as per Monastery guidelines
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with JComboBox
by JamesNC (Chaplain) on Nov 17, 2004 at 04:12 UTC | |
by ChrisR (Hermit) on Nov 17, 2004 at 14:25 UTC | |
by JamesNC (Chaplain) on Nov 17, 2004 at 20:56 UTC | |
by TonyDonker (Novice) on Feb 14, 2005 at 08:50 UTC | |
by JamesNC (Chaplain) on Feb 14, 2005 at 14:49 UTC | |
| |
|
Re: Help with JComboBox
by graff (Chancellor) on Nov 17, 2004 at 05:32 UTC | |
by JamesNC (Chaplain) on Nov 17, 2004 at 12:46 UTC | |
|
Re: Help with JComboBox
by jdtoronto (Prior) on Nov 16, 2004 at 22:43 UTC | |
by ChrisR (Hermit) on Nov 17, 2004 at 02:17 UTC | |
|
Re: Help with JComboBox
by diakonos (Hermit) on Nov 16, 2004 at 20:12 UTC | |
by ChrisR (Hermit) on Nov 16, 2004 at 20:17 UTC |