AW: How to create a hyperlink within a text field?

Tiemo Hollmann TB toolbook at
Thu Feb 4 03:17:43 EST 2016

Thanks Jacque,
I like it everytime to see the variety of solutions on the same issue. I
think yours is the most elegant and compact one.

-----Ursprüngliche Nachricht-----
Von: use-livecode [mailto:use-livecode-bounces at] Im Auftrag
von J. Landman Gay
Gesendet: Donnerstag, 4. Februar 2016 05:38
An: How to use LiveCode <use-livecode at>
Betreff: Re: How to create a hyperlink within a text field?

A little trick:

Create or import a transparent 1x1 pixel image. Hide it. Make each line in
the table of contents into linked text. The html of each line looks like

<a>Chapter one</a>

In the body text of the field, place a marker character before the chapter
heading. I'm using "#", like this:

#Chapter One

Then set the imagesource of char 1 of the line to the ID of the transparent
image. You won't be able to see the first character after that but the text
is still there. The htmltext of that line looks like this:

<p><img src="1036" char="#">Chapter One</p>

The line will be slightly indented by one pixel, but it shouldn't be
noticeable. If you center the heading, it is imperceptible.

In the field script:

on linkclicked pURL
   put "#" before pURL
   put lineoffset(pURL, the formattedtext of me) into tLineNum
   set the scroll of me to the effective textheight of me * (tLineNum-1) end

If you choose a marker character that doesn't exist in the body text,
lineoffset will always return the correct line.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

use-livecode mailing list
use-livecode at
Please visit this url to subscribe, unsubscribe and manage your subscription

More information about the use-livecode mailing list