Hi everyone, I have searched through MTK and the pod docs and experimented myself but I'm still stumped.
The code below shows that if I bind a widget to a virtual event it only responds to the event if it (the widget bound to the event) generates the event. My goal is to have the widget respond to the event no matter who/what generated the event. Am I on the right track?
#!/usr/bin/perl
use Tk;
use strict;
my $app = new MainWindow;
my $entry = $app->Entry()->pack();
$entry->bind('<<customEvent>>' => \&respondToEvent);
$app->Button(-text => 'gen event by app',
-command => [\&sendEvent, 0])->pack();
$app->Button(-text => 'gen event by label',
-command => [\&sendEvent, 1])->pack();
MainLoop;
sub sendEvent {
if(@_[0]) {
# have entry generate event - this works
$entry->eventGenerate('<<customEvent>>');
} else {
# have mainwindow generate event - this produces nill
$app->eventGenerate('<<customEvent>>');
}
}
sub respondToEvent {
print "Responding to Event!";
}