Re: (fwd) manipulating a derived Tk::Text widget

Steve Lidie <[email protected]>
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
On Feb 3, 2005, at 3:07 PM, Steve Lidie wrote:

> Hi,
>
> Yesterday a question was asked how to filter Control-g
> characters from printing.
>
> Well Marc Dashevsky had posted an earlier solution where
> he made a new text package like this:
>
> ####################################################33
> package Tk::MyText;
> require Tk::Text;
> use base qw/Tk::Text/;
> Construct Tk::Widget 'MyText';
>
> sub InsertKeypress {
>   my($w, $char) = @_;
>    if (ord($char) < 27) {
>      print chr(ord($char) | 0x40), "\n";
>      # only Control-G/J/L/M/Q/R/S/U/W/Y/Z are making it to here
>    } else {
>   $w->SUPER::InsertKeypress($char);
>   }
> }
> ######################################################
>
> Ok that works good.  But I noticed that if I add the line
>
> $mw->bind($class,'<Control-KeyPress>','NoOp');
> to the
> sub  bindRdOnly
> in Text.pm, it works well.
>
>
> So how do you make a package derived from Tk::Text,
> which does just one thing:
> add
> $mw->bind($class,'<Control-KeyPress>','NoOp');
> to the
>
> sub  bindRdOnly{}
>
> in Text.pm?
>
> Thanks.  I probably can figure this out by experimenting and
> hacking, but I figure there is a right way to do it. :-) I better ask.
>

It's all explained in MPTK - you override ClassInit() in the 
mega-widget to adjust your new class' bindings ;)

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.