my $id = $sel || (@ids && $ids[0]) || ''; my $IDText = $dlg->add ( 'JComboBox', -options => \@ids, -mode => 'readonly', -selectcommand => [\&changeEditPlayer, \$id], -validate => 'match', -textvariable => \$id, ); # $IDText->configure (-options => \@ids); $IDText->setSelected ($id); return if $dlg->Show (-global) ne 'OK'; } #### #!/usr/bin/perl use strict; use warnings; use Tk; use Tk::DialogBox; use Tk::JComboBox; my $main = MainWindow->new (-title => "Test JComboBox"); EditPlayers ($main); sub EditPlayers { my ($main, $sel) = @_; my @ids = qw(Fred Joe Bob); my $dlg = $main->DialogBox (-title => "Member Information", -buttons => ["OK", "Cancel"]); my $IDText = $dlg->add ( 'JComboBox', -options => \@ids, -mode => 'readonly', -selectcommand => [\&changeEditPlayer, \$ids[0]], -validate => 'match', -textvariable => \$ids[0], ); $IDText->form (-left => '%0', -right => '%100', -top => '%0'); # $IDText->setSelected ($ids[1]); #works return if $dlg->Show (-global) ne 'OK'; } sub changeEditPlayer { my ($id, $widget, $index, $value, $name) = @_; return 1 if ! defined $name; print "$name\n"; }