#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my $t = $mw->Scrolled('Text', -scrollbars => 'osoe' )->pack; for(1..100){ $t->tagConfigure( 'data'.$_, -data => $_ x 20, ); } for(1..100){ $t->insert('end', 'Line'."$_\n", ['datarider','data'.$_ ]); } $t->tagBind( 'datarider', '<Enter>', sub { getdata($t) } ); $t->tagBind( 'datarider', '<Leave>', sub { getdata($t) } ); $t->bind( '<Motion>', sub{ getdata($t) } ); MainLoop; sub getdata { my ( $text_widget ) = @_; my $x = $text_widget->pointerx - $text_widget->rootx; my $y = $text_widget->pointery - $text_widget->rooty; #print "$x $y\n"; my $txt_index = $text_widget->index( '@' . $x . ',' . $y ); #warn $txt_index; my ( $line, $char ) = ( $txt_index =~ /^(.+?)\.(.+?)$/ ); my @tags = $text_widget->tagNames($txt_index); print "@tags\n"; foreach my $tag(@tags){ print $text_widget->tagCget($tag,'data'),"\n"; } }
In reply to Re: checking existence of a tag in a TK::Text?
by zentara
in thread checking existence of a tag in a TK::Text?
by jsteng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |