RE: [tcltk-perl] Change the way that %-subs are handled.
Brought to you by:
hobbs
From: Jeff H. <je...@Ac...> - 2004-04-21 19:23:40
|
> >$mw->bind('<Motion>', [$sub, Tcl::EV('%X', '%Y'), '<Motion>']); > [...] > > You could auto-prepend each %, but I think > >it's good to keep the logical connection of %-sub there. > > I would think the Tcl::EV name already provides the > connection to event variables, so I would shorten this to: > > $mw->bind('<Motion>', [$sub, Tcl::EV('XY'), '<Motion>']); > > Or do you expect to ever require multi-character variable names here? The documentation for Tcl always refers to %a, %b, etc, but I see that Perl/Tk removes the percent and uses Ev('a'). Of course, their Ev does other things that are ... odd, and more specifically, their docs aren't scrubbed of many other references to %a, %b, etc in doc details. I'm not stuck on Tcl::EV taking '%a', '%b' vs 'ab', but one advantage is that, as you can see from the super-simple implementation: sub EV { my @events = @_; return bless \@events, "Tcl::EV"; } I don't actually process the args ... which means I can use this for other means, like: $mw->bind('<3>', [\&mysub, Tcl::EV('[winfo class %W]', '%X', '%Y')]); as the args are just passed right on to Tcl and are evaled there before the callback into Perl. So do you still think it's work "simplifying"? Jeff |