Creating Hypertext Links in Fields
Creating hyperlinks in field objects.
Description: This tutorial explains how to use the textStyle and textLink properties to create hypertext links within a locked text field.
Creating your text field.
Adding text to your text field.
3. Enter the following in the text field by either switching to browse/run mode and entering the text directly or by entering it into the "Contents" section of the field's Object Inspector, obtained by first clicking on the field to make it active and then performing the menu command Object -> Object Inspector:
Click here to go to RunRev's site. -- this is the beginning of the text to enter into the text field
Click here to go to a card with
more information. -- this is the end of the text to enter into the text field
4. Using the Object Inspector, name the field "text" or some such thing. While this step isn't really necessary, it is good practice to give objects names that are easily remembered.
Setting the textStyle to link.
6. Open the message box and type the following, followed by a return/enter:
set the textStyle of word 2 of line 1 of fld "text" to link -- this sets the second word of the first line as having a link textStyle.
This should result in the indicated word having a blue, underlined, link appearance.
Linking the link to a destination (website).
7. Enter the following in the message box, followed by a return/enter:
set the linkText of word 2 of fld "text" to / "http://www.runrev.com" -- this makes the link, when clicked, open a web browser that opens this URL.
8. Repeat instruction 6, changing the chunk descriptor to reflect the second "here" in the text field.
Linking the link to a destination (a card in your stack).
9. Repeat instruction 7 but, instead of the URL, give the destination as "card 2" or whatever you have named card 2.
Locking the text field
Scripting the Locked Field
11. We will now script the field to handle the links being clicked and directing the user to the desired location. To do so, select the text field by clicking on it, perform the menu command Object -> Object Inspector, and click on the little triangle on the right which brings up further options, including "Edit Script"; select "Edit Script". (Alternatively, you can access it directly by using command-e or your systems appropriate keyboard accelerator combination).
Save and test!
13. Save your stack by performing the menu command File -> Save As...
If, for some reason, you'd like a copy of this stack, visit http://jperryl.ecs.fullerton.edu/Hyperlinks.zip