use Tk; use Tk::TextUndo; package Tk::TextUndo; sub InsertKeypress { my ($w,$char)=@_; return if $char eq ''; if ($char =~ /^\S$/ and !$w->OverstrikeMode and !$w->tagRanges('sel')) { my $index = $w->index('insert'); my $undo_item = $w->getUndoAtIndex(-1); if (defined($undo_item) && ($undo_item->[0] eq 'delete') && ($undo_item->[2] == $index) ) { $w->SUPER::insert($index,$char); $undo_item->[2] = $w->index('insert'); $w->see('insert'); #######ergaenzt return; } } $w->addGlobStart; $w->SUPER::InsertKeypress($char); $w->addGlobEnd; } package main; my $mw = tkinit; my $testundo = $mw-> Scrolled ('TextUndo', -wrap => 'none',)-> pack (); MainLoop;