If I want to dynamically assign the value of -balloonmsg, for example the content of the tagged text? In the following I have 2 words tagged, the balloon should diasplay as message the respectiv text which is tagged. I simulate this reading the content with "get", but I use fix indexes and of course it is not okay. Any idea how to get those indexes dynamically?
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Text; use Tk::Balloon; my $mw = tkinit(); my $text = $mw->Text->pack; $text->insert('end', "This is a red text\n"); $text->tagAdd('red_text', '1.10', '1.13'); $text->insert('end', "This is another xxx text\n"); $text->tagAdd('red_text', '2.16', '2.19'); $text->tagConfigure('red_text', -foreground => 'red'); my %messages = (1=>"hello", 2=>"good"); my $balloon = $text->Balloon(); $text->tagBind('red_text', '<Enter>', sub { my $message= $text->get('1.10', '1.13');# this should become dynam +ic $balloon->attach($text , -balloonmsg => $message, -initwait => 10, -balloonposition => 'mouse'); }); $text->tagBind('red_text', '<Leave>', sub { $balloon->detach($text) }) +; $mw->MainLoop();
In reply to Re^2: Attaching a balloon message to text on the Text widget
by Anonymous Monk
in thread Attaching a balloon message to text on the Text widget
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |