$text = $mw->TextConfig('Text'); # or
$text = $mw->TextConfig('SuperText'); # or
$text = $mw->TextConfig('ROText');
# etc
####
package Tk::TextConfig;
use strict;
use Tk;
our @ISA;
use base qw(Tk::Derived);
Construct Tk::Widget 'TextConfig';
sub new {
my $package = shift;
my $parent = shift;
my $kind = shift;
my $targetclass = "Tk::$kind";
eval "require $targetclass";
push @ISA, $targetclass;
my $object = $targetclass->new($parent, @_);
bless $object, "Tk::TextConfig"; # reblessing ?
return $object;
}
my $LinkTagPrefix = 'Link_';
sub insertLink {
my ($self, $index, $chars, $action) = @_;
my $cnt = ++$self->{'TCcounters'}{'link'};
my $uniquename = $LinkTagPrefix.$cnt;
$self->insert($index, $chars, $uniquename);
$self->tagConfigure($uniquename, qw/-foreground blue -underline 1 -data/, $action);
# ......
$self->tagBind($uniquename, '', 'keyLink'); # Wrong
# This kind of binding has strange behaviour (bug?)
# It is related to the 'current' mark instead of the 'insert'.
# So it depends on mouse position
# Anyway, it seems that Tk::Text tag bindings has noting common with widget's bindings
# Actually we cannot do Tk->break from sub keyLink
}
####
use strict;
use Tk;
use Tk::TextConfig;
my $mw = MainWindow->new;
my $text = $mw->TextConfig(qw/Text -height 30/)->pack(qw/-expand 1 -fill both/);
for my $i (1..200) {
$text->insertLink('end', 'Linktext', 'Some data');
$text->insert('end', ". \n -");
}
foreach my $tag ($text->bindtags) {
print " bindtag tag '$tag' has these bindings:\n";
print " ", $text->bind($tag), "\n";
}
MainLoop();