Using break in callback function with Tcl::Tk
[email protected] Sun, 19 Jan 2020 10:54:17 +0100
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <trinity-c3b9a65b-63d1-40c5-a16b-a371d35c57f0-1579427657331@3c-app-gmx-bs76> |
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div class="signature">Hello everybody,</div>
<div class="signature"> </div>
<div class="signature">
<div>Does anybody know, how to use the tcl "break" function in a Tcl::Tk event callback. I saw https://www.perlmonks.org/?node_id=1026146 but I cannot make head or tail of it.<br/>
<br/>
Here is my simple try, that doesn't work:<br/>
</div>
<div>use Tcl::Tk;<br/>
my $int = Tcl::Tk->new();<br/>
my $mw = $int->mainwindow();<br/>
my $b = $mw->Text()->pack();<br/>
$b->bind('<Enter>' => \&enter);<br/>
$b->bind('all','<Enter>' => sub {print "This shouldn't be printed\n";});<br/>
$int->MainLoop;<br/>
sub enter {<br/>
print "hello\n";<br/>
eval {<br/>
$int->Eval('-code break'); <br/>
};<br/>
<br/>
}<br/>
<br/>
Without the eval in the function enter, I get an error: "command bound to event"..<br/>
<br/>
Thanks in advance for any help,<br/>
Max<br/>
<br/>
PS.: Appending a binding with "bind $w +command" works as follows ;-) :<br/>
$int->CreateCommand('ent',\&enter);<br/>
$b->bind('<Enter>' => '+ent');</div>
</div></div></body></html>