#!/usr/bin/perl use warnings; no warnings "redefine"; use Tk; use Tk::TableMatrix; sub Tk::TableMatrix::Paste { print "start\n"; my $w = shift; my $cell = shift || ''; ## Perltk not sure if translated correctly my $data; if ($cell ne '') { eval{ $data = $w->GetSelection(); }; return if($@); } else { eval{ $data = $w->GetSelection('CLIPBOARD'); }; return if($@); $cell = 'active'; } $w->PasteHandler($w->index($cell),$data); $w->focus if ($w->cget('-state') eq 'normal'); print "end\n"; } my $top = MainWindow->new; my $arrayVar = {}; foreach my $row (0..20){ foreach my $col (0..10){ $arrayVar->{"$row,$col"} = "r$row, c$col"; } } my $t = $top->Scrolled('TableMatrix', -rows => 21, -cols => 11, -width => 6, -height => 6, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -selectmode => 'extended', -resizeborders => 'both', -titlerows => 1, -titlecols => 1, -bg => 'white', # -state => 'disabled' # -colseparator => "\t", # -rowseparator => "\n" ); $t->tagConfigure('active', -bg => 'gray90', -relief => 'sunken'); $t->tagConfigure( 'title', -bg => 'gray85', -fg => 'black', -relief => 'sunken'); # $t->bind("", sub { $t->focus }); $t->pack(-expand => 1, -fill => 'both'); Tk::MainLoop; #### #!/usr/bin/perl use warnings; use strict; use Tk; 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); } } package main; my $top = tkinit; my $text = $top->MyText->pack; $text->eventAdd('<>' => '',''); $text->bind('<>', sub { $text->insert('end'," <-- How do I supress this?\n") }); print $text->eventInfo('<>'); MainLoop; #### #!/usr/bin/perl use warnings; use strict; use Tk; package Tk::MyText; require Tk::Text; use base qw/Tk::Text/; Construct Tk::Widget 'MyText'; sub ClassInit { print "ClassInit [@_]\n"; my($class,$mw) = @_; $class->SUPER::ClassInit($mw); $mw->bind($class,'','NoOp'); $class; } ##################################################### package main; my $top = tkinit; my $text = $top->MyText->pack; $text->eventAdd('<>' => '',''); $text->bind('<>', sub { $text->insert('end'," <-- How do I supress this?\n") }); print $text->eventInfo('<>'); MainLoop;