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">&nbsp;</div>

<div class="signature">
<div>Does anybody know, how to use the tcl &quot;break&quot; 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/>
&nbsp;<br/>
Here is my simple try, that doesn&#39;t work:<br/>
&nbsp;</div>

<div>use Tcl::Tk;<br/>
my &#36;int = Tcl::Tk-&gt;new();<br/>
my &#36;mw = &#36;int-&gt;mainwindow();<br/>
my &#36;b = &#36;mw-&gt;Text()-&gt;pack();<br/>
&#36;b-&gt;bind(&#39;&lt;Enter&gt;&#39; =&gt; &#92;&amp;enter);<br/>
&#36;b-&gt;bind(&#39;all&#39;,&#39;&lt;Enter&gt;&#39; =&gt; sub {print &quot;This shouldn&#39;t be printed&#92;n&quot;;});<br/>
&#36;int-&gt;MainLoop;<br/>
sub enter {<br/>
&nbsp;&nbsp; &nbsp;print &quot;hello&#92;n&quot;;<br/>
&nbsp;&nbsp; &nbsp;eval {<br/>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&#36;int-&gt;Eval(&#39;-code break&#39;);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br/>
&nbsp;&nbsp; &nbsp;};<br/>
&nbsp;&nbsp; &nbsp;<br/>
}<br/>
&nbsp;<br/>
Without the eval in the function enter, I get an error: &quot;command bound to event&quot;..<br/>
&nbsp;<br/>
Thanks in advance for any help,<br/>
Max<br/>
&nbsp;<br/>
PS.: Appending a binding with &quot;bind &#36;w +command&quot; works as follows ;-) :<br/>
&#36;int-&gt;CreateCommand(&#39;ent&#39;,&#92;&amp;enter);<br/>
&#36;b-&gt;bind(&#39;&lt;Enter&gt;&#39; =&gt; &#39;+ent&#39;);</div>
</div></div></body></html>