Ok, here is the solution. First, you are using the same textvariable reference and that is why the box pops up, use a second one and that issue goes away. The other problems are caused by the fact that you keep creating instances of dialog boxes and JCombo's. Create a single instance, and then use the Show() method in your CallDialog sub. Here is your version hacked up to work:
use strict; use warnings; use Tk; use Tk::JComboBox; use Tk::Dialog; my $form; my %choices = ( 'a'=>1, 'b'=>2, 'c'=>3 ); my $selected_1 = "a"; my $selected = "a"; my $dialog; my $testbox1; my $testbox2; CreateMainForm(); MainLoop(); sub CreateMainForm { $form = MainWindow->new(); $form->title("Test for JComboBox Problem"); $testbox1 = $form->JComboBox( -textvariable=>\$selected_1, -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'); $dialog = $form->Dialog ( -title=>"Part2 of test", -buttons=>["Submit","Cancel"],-default_button=>"Submit" ); $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'); } sub CallDialog { $testbox1->configure(-state=>'disabled'); my $retval = $dialog->Show( -popover=>$form, -overanchor=>'c', -popanchor=>'c'); if($retval eq "Cancel") { $testbox1->configure(-state=>'normal'); } elsif($retval eq "Submit") { $testbox1->configure(-state=>'normal'); $testbox1->setSelected($selected ); #(optional?) } }


Cheers,
JamesNC

In reply to Re: Help with JComboBox by JamesNC
in thread Help with JComboBox by ChrisR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.