Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi, an interesting question has come up on comp.lang.perl.tk, which got me thinking on how to generally solve an "object modification" problem.
The original problem was how to prevent a Tk::Text widget from printing control characters. For instance in this code: So I looked into the Tk::Text module and right at the top, there is a sub bindRdOnly{}, to which if I add the line It modifies the Text widget to ignore printing Control chars. I know it works, because I copied Text.pm to the '.' directory, modified it, and ran it as Tk::Text. That is a clunky solution, which I'm embarrased to tell people is a solution, especially since Tk::Text has an xs component and can't just be renamed. So my understanding of deriving one module from another is not the best. So how do I do one thing....add that binding to make a new package. A similar Tk::Text widget can be made like this: (code from Marc Dashevsky) This one filters the Control keypresses thru the InsertKeypress sub, but it would be nicer to do it through the bindRdOnly sub. Anyone know how to make this simple addition to a module's subroutine to make a different derived package? It is not as simple as just pushing the statement into an array or hash in the package, the sub bindRdOnly{} is just a series of bind statements. Thanks I'm not really a human, but I play one on earth. flash japh In reply to Making a derived Tk::Text object by zentara
|
|