Tk-JComboBox 1.12 has been uploaded to CPAN. I think it will resolve this issue. This release also includes minor updates to the docs and test cases. It also features a new examples directory that should grow larger over time. Here is a relevant example that demonstrates -popupcreate
use Tk;
use Tk::JComboBox;
my $mw = MainWindow->new;
my $entry = $mw->Entry->pack;
my $jcb = $mw->JComboBox(
-choices => [qw/one two three four/],
-entrywidth => '16',
-highlightthickness => 0,
-listwidth => '16',
-mode => 'readonly',
-popupcreate => \&addItems,
)->pack;
MainLoop;
sub addItems {
my @items = split(/ /, $entry->get());
$jcb->removeAllItems;
$jcb->configure(-choices => \@items) if @items;
}
For versions 1.11 and earlier the following serves
as a partial workaround to the issue with -popupcreate. The last line can be included in callbacks to take care of Popup layout/positioning issues.
sub addItems {
my @items = split(/ /, $entry->get());
$jcb->removeAllItems;
$jcb->configure(-choices => \@items) if @items;
$jcb->PopupCreate;
}
Note that this will still have a problem if the JComboBox is empty, because the popupcreate callback will not get triggered. Version 1.12 accounts for this.
Rob