How to create hypertext links
Dave Cragg
dcragg at lacscentre.co.uk
Fri Apr 7 18:36:53 EDT 2006
On 7 Apr 2006, at 22:42, Bob Wilson wrote:
> I have a situation where I need to load forms with text that
> includes links.
> Right now, they are stored in the source database as follows:
>
> The <j>rain in Spain</j> falls mainly in the plains.
>
> The text to be hyperlinked is "rain in Spain". The <j> and </j>
> are not to
> be displayed.
>
> I can't find anything in the Revolution documentation that describes
> hypertext-like characters that I can preload in the text stream to
> create
> linked text segments.
>
> So my question is - what's the best way to load this text and
> create linked
> segments while I'm loading it.
It depends on exactly how you want to use the link, but take a look
at linkText and linkClicked in the docs.
The simplest way would be just to replace the <j> and </j> with <a>
and </a> respectively. Then set the htmlText of the field to the
string. For example:
set the htmlText of field 1 to "The <a>rain in Spain</a> falls
mainly in the plains."
The will display the link with an underline. If you click on the
link, the linkClicked message will be sent to the field, passing
"rain in Spain" as a parameter.
If you'd rather the linkClicked message was sent something else as a
parameter (an index number, for example) you could set alternative
linkText like this:
set the htmlText of field 1 to "The <a href="9">rain in Spain</a>
falls mainly in the plains."
Then in the field script, you would have a linkClicked handler like
this (this assumes there will be other link text in the field, and
that teh links are set up as in the first exampe above.)
on linkClicked pLinkText
switch pLinkText
case "rain in Spain"
play audioclip "rineinspine" ## or whatever
break
case "she sells"
play audioclip "sea shells"
break
end switch
end linkClicked
There are some restrictions on the use of the linkClicked message. I
think the field has to be locked, and it won't work with a list field.
Cheers
Dave
More information about the use-livecode
mailing list