NAME
Term::Fabulous::Event::LinkActivate - The user followed a link of a RichText
SYNOPSIS
$help->on( LinkActivate => sub ($event) {
open_page( $event->link ); # the link's target
return;
} );
DESCRIPTION
A Term::Fabulous::Widget::RichText fires LinkActivate on itself when the user follows one of its links, whichever way: a left click on the link, or Enter while the RichText has the focus and a link is selected. $rich_text->activate_link fires it from code. The widget does not go anywhere itself: what a link means is the program's business, and link is the target the program gave it.
It is a Clay::UI::Events::Event whose name is LinkActivate, and it bubbles from the RichText to its ancestors, so a container can follow the links of every text inside it. $event->target is the RichText (target is the widget, as for every event; the link's target is link).
CONSTRUCTOR
new
my $event = Term::Fabulous::Event::LinkActivate->new(
link => 'https://perl.org',
index => 0,
start => 4,
end => 12,
);
The RichText builds these events itself; build one yourself to test your listeners, or to fire it from a widget of your own that shows links some other way. All four parameters are required; link may be anything but undef, the others are non-negative integers with start <= end. Unknown parameters die. The name and bubble_mode parameters of Clay::UI::Events::Event are accepted.
METHODS
link
my $target = $event->link;
The target of the link: a string from markup, or whatever the program gave add_link.
index
my $index = $event->index;
The index of the link among the RichText's links.
start
my $start = $event->start;
The offset of the link's first character in the text.
end
my $end = $event->end;
The offset after the link's last character.
SEE ALSO
"LINKS" in Term::Fabulous::Widget::RichText, Term::Fabulous::Event::TextClick, Term::Fabulous::Manual::Events, and the recipe "Follow links in a text (RichText links)" in Term::Fabulous::Cookbook::KeyboardAndMouse.