OK, yes, thanks, that sounds like a possible good solution. I like the idea of subclassing the widget, and then redefining the Paste sub with a minor modification.

I guess I was sort of afraid to look in the TableMatrix.pm file because I didn't think I would understand it. But it looks like TableMatrix.pm is just the default bindings plus some useful interface functions such as Paste. Not too scary afterall. (though I definitely don't "get" everything.)

Also, I sort of assumed if a sub wasn't mentioned in the documentation that it was considered "private" and I wasn't supposed to use it unless I really know what I'm doing. But I guess I could say now that I know that's what I need to do.

(I do think making a subclass is the best way to go (I love OO), but another possible solution it seems, (now that I know there is a Paste sub I can call) would be to just rebind <Control-v> to my own sub and I could do my 'before and after' code with a call to Paste in between. Though I would also need to rebind <ButtonRelease-2>.)

back to your your example: in the Paste() redefine above, you could instead of writing all the original Paste code in between

print "start paste\n"; my $w = shift; my $cell = shift || ''; ## Perltk not sure if translated correctly
and print "end paste\n";, you could just call $w::SUPER->Paste($cell); Is that correct? I read a couple of the tutorials on OO with Perl, but I haven't really put it to use yet.

Thanks again so much for the reply. You were very helpful.


In reply to Re^2: how to modify a built-in event (capturing a paste operation in Tk::TableMatrix) by gleepglop
in thread how to modify a built-in event (capturing a paste operation in Tk::TableMatrix) by gleepglop

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.