Hello Monks,
I have a perltk program with several widgets that display data in different ways. I want to send a "<<record_added>>" event and have anything that should do something ... do it. But it seems that only the last widget bound to the event will find out about the event. The code below shows an example of this:
use Tk;
my $app = new MainWindow;
my $entry1 = $app->Entry()->pack();
my $entry2 = $app->Entry()->pack();
$entry1->bind('all', '<<customEvent>>' => sub{ print "entry 1" });
$entry2->bind('all', '<<customEvent>>' => sub{ print "entry 2" });
$app->Button(-text => 'gen event',
-command => sub{ $app->eventGenerate('<<customEvent>>')}
+)->pack();
MainLoop;
Do I just have the wrong mindset or am I doing something wrong in the code? I would think that once an event was fired off every widget would get a chance at responding to it; at least every widget you asked to listen for it.
Thanks,
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.