Leser: 2
7 Einträge, 1 Seite |
$main::widgets{textfeld}-> bind ('<Key>', sub {$main::widgets{textfeld}-> see ('insert');});
$main::widgets{textfeld}-> xviewMoveto(1);
1
2
3
4
5
6
7
8
use Tk;
use Tk::TextUndo;
my $mw = tkinit;
my $testundo = $mw-> Scrolled ('TextUndo', -wrap => 'none',)-> pack ();
MainLoop;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
7 Einträge, 1 Seite |