in reply to Re: problem with Tk::JComboBox
in thread problem with Tk::JComboBox

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

Replies are listed 'Best First'.
Re^3: problem with Tk::JComboBox
by jethro (Monsignor) on Sep 22, 2008 at 19:08 UTC
    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

        That is not a bug, it's a feature. JComboBox recognizes when you use the same var for more than one box. The first box is called the master, all the others observer. If you change the master, the observers follow.

        Really a strange "feature" IMHO, but it is documented, in the section "The Choices option" of the JComboBox docs

      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.
        You mean the feature of connected boxes? I did say it is a feature, not a bug. And you can use it by creating an array and using a reference to it as a -choices parameter. For example:
        my @array= ('1', '2','123'); my $box1 = $Screen->JComboBox( ... , -choices= \@array ); my $box2 = $Screen->JComboBox( ... , -choices= \@array );

        As long as you use a reference to the same array, the boxes are in sync to the first box, the master. At least that's how I understood the documentation.