Using break in callback function with Tcl::Tk

[email protected] Sun, 19 Jan 2020 10:56:58 +0100
Newsgroups perl.tcltk
Message-ID <trinity-bb279420-c174-4289-9bb7-cbb1189c9ebf-1579427818766@3c-app-gmx-bs23>
Hello everybody,
=C2=A0
Does anybody know, how to use the tcl "break" function in a Tcl::Tk event =
callback=2E I saw https://www=2Eperlmonks=2Eorg/?node_id=3D1026146 but I ca=
nnot make head or tail of it=2E
=C2=A0
Here is my simple try, that doesn't work:
=C2=A0
use Tcl::Tk;
my $int =3D Tcl::Tk->new();
my $mw =3D $int->mainwindow();
my $b =3D $mw->Text()->pack();
$b->bind('<Enter>' =3D> \&enter);
$b->bind('all','<Enter>' =3D> sub {print "This shouldn't be printed\n";});
$int->MainLoop;
sub enter {
=C2=A0=C2=A0 =C2=A0print "hello\n";
=C2=A0=C2=A0 =C2=A0eval {
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0$int->Eval('-code break');=C2=A0=C2=
=A0 =C2=A0=C2=A0=C2=A0 =C2=A0
=C2=A0=C2=A0 =C2=A0};
=C2=A0=C2=A0 =C2=A0
}
=C2=A0
Without the eval in the function enter, I get an error: "command bound to =
event"=2E=2E
=C2=A0
Thanks in advance for any help,
Max
=C2=A0
PS=2E: Appending a binding with "bind $w +command" works as follows ;-) :
$int->CreateCommand('ent',\&enter);
$b->bind('<Enter>' =3D> '+ent');