#... code
my $id = $sel || (@ids && $ids[0]) || '';
print "id 1 is <$id>\n";
my $IDText = $dlg->add (
'JComboBox',
-mode => 'readonly',
-selectcommand => [\&changeEditPlayer, \$id],
-validate => 'match',
-textvariable => \$id,
);
print "id 2 is <$id>\n";
####
$id = "Joe";print "id is not Joe!! <$id>\n";
$IDText->form (-left => '%0', -right => '%100', -top => '%0');
$IDText->configure (-options => \@ids);
# not only sets the selection but calls changeEditPlayer
$id = "Joe"; print "now id is not empty!! <$id>\n";
# does nothing, because 'Sandy' is not a valid option
$id = "Sandy"; print "id not set to Sandy because it is an invalid option <$id>\n";
$id = $sel || (@ids && $ids[0]) || '';
### now it works !!
$IDText->setSelected ($id); # dosn't work
####
id 1 is
id 2 is <>
id is not Joe!! <>
- inside changeEditPlayer Joe
now id is not empty!!
id not set to Sandy because it is an invalid option
- inside changeEditPlayer Fred
####
$id = 'Sandy';
print "<$id>\n"; # prints Joe