in reply to problem with Tk::JComboBox

Zentara already said the important things. But I think it really was your intention to have the selection of the second widget change when the first widget is selected as in your script. In that case you only need to change Zentaras script this way:

sub ComboBoxSelect { my $list = shift; print "Browsing $list\n"; if ($list == 1) { my @TestList1 = ('a','b','cde'); $box{2}{'obj'}->configure(-choices => \@TestList1,-state => 'norma +l'); } }

If you prefer to have separate browsecmd functions for your widgets, you still can do that with Zentaras version. Just give a subroutine reference as a fifth parameter to createComboBox

UPDATE: The original program of AnonMonk works when the line @TestList1 = ('1','3','125'); is moved out of the callback routine to the end of the Screen routine. Looks like a bug in JComboBox to me

Replies are listed 'Best First'.
Re^2: problem with Tk::JComboBox
by zentara (Cardinal) on Sep 22, 2008 at 18:24 UTC
    I wonder why you can't have a common browsecmd, and pass in a parameter, without them interfereing with one another.....seems like a bug. JComboBox must be doing something globally in the module.

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Which interference are you refering to? I just installed JComboBox and tested all the scripts superficially and they seemed to work as expected (Apart from the bug(?) with @TestList1 in the callback)
        In my code above, when you run it, and hit the down arrow on the top box, then browse the selections, the browsecmd callback will say Browse 1. So the selections to the top box only should change. BUT if you then proceed to the bottom box 2, it's selections will have been changed too, without browsing them.

        The reverse is not the same. If you restart the app, and browse the lower box 2, it will change it's selections. Then proceed to the top box 1, and it's selections have not changed.

        Also, if you browse box 1 first, it will print Browse 1 only when you actually browse the selections. Then if you go to the down arrow on box 2, it will print Browse 1, on the arrow press of box 2. Maybe it's a focus thing, but it sure seems like there is something wrong with the way the browsecmd works with multiple boxes.


        I'm not really a human, but I play one on earth Remember How Lucky You Are
        how can i achive as you mentioned as bug.
        even i won't use only one place, i will use dependent select combo's in differt screens.
        Please suggest me.