For example in the following script:
use Tk;
my $mw = new MainWindow;
my $t = $mw->Scrolled("Text")->pack;
my $popup = $mw->Menu(
-menuitems => [
[
Button => 'Copy Selected',
-state => "disabled",
-command => sub {$t->clipboardColumnCopy}
],
]
);
$t->menu($popup);
MainLoop;
How do I tell when selection happens so that I can use the following code
$popup->entryconfigure(1, -state=>'normal');
to change the menu item state?
UPDATE:
Big thanks to @Chas and @gbacon :)
I think maybe I can also combine the two good answers:
$t->bind(
"<Button1-ButtonRelease>",
sub {
local $@;
my $state = defined eval { $t->SelectionGet } ?
"normal" : "disable";
$popup->entryconfigure(1, -state => $state)
}
);