sub native_optionmenu {
my($parent, $varref, $command, @optionvals) = @_;
$$varref = $optionvals[0];
my $mb = $parent->Menubutton(
-textvariable => $varref,
-indicatoron => 1,
-relief => 'raised',
-borderwidth => 2,
-highlightthickness => 2,
-anchor => 'c',
-direction => 'below',
);
my $menu = $mb->Menu(-tearoff => 0);
$mb->configure(-menu => $menu);
my $callback = ref($command) =~ /CODE/ ? [$command] : $command;
foreach (@optionvals) {
$menu->radiobutton(
-label => $_,
-variable => $varref,
-command => [@$callback, $_],
);
}
$mb;
}
####
sub update_native_optionmenu_options {
my($native_nm, $varref, $command, $ref_optionvals) = @_;
my ($menu, $callback);
$$varref = $ref_optionvals->[0];
$callback = ref($command) =~ /CODE/ ? [$command] : $command;
foreach (@$ref_optionvals) {
$menu = $native_nm->cget(-menu);
$menu->radiobutton(
-label => $_,
-variable => $varref,
-command => [@$callback, $_],
);
}
}
####
update_native_optionmenu_options(
$nm_wg,
\$nm_string,
[sub {print "native om = @_.\n"}, 'First'],
\@nm_local_options);