[tcltk-perl] Change the way that %-subs are handled.
Brought to you by:
hobbs
From: Jeff H. <je...@Ac...> - 2004-04-21 04:49:22
|
I finally figured out the magic that makes the commands that require %-substitutions to work, like so: my $sub = sub { my ($X, $Y) = (Tcl::Ev('X'), Tcl::Ev('Y')); print "X: $X Y: $Y\n"; }; $mw->bind('<Motion>', \\'XY', $sub); This double-reference to the scalar seems a little weird to me. It would of course be best if we could somehow manage to get the substitutions as part of the command. Now that we properly handle command callbacks with args, I would like to recommend this alternative: $mw->bind('<Motion>', [$sub, Tcl::EV('X', 'Y', ...), "foo", ...]); This would magic convert to the either the same special things that requires the Tcl::Ev in the sub, or perhaps (if I can make the magic work), have it pass the %-subs to the Tcl side of the callback, while maintaining the "foo", ... for the perl side. Any objections, or better ideas? -- Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos |