Page 1 of 1
Spotting a hyperlink?
Posted: Sun May 11, 2025 6:23 pm
by richmond62
Let's suppose I have a text file that contains the word 'potatoes', and I read it into a textField "BigGUFF". . .
Now for every incidence of the word 'potatoes' I want to make the word 'potatoes' blue, and hyperlink it to another field called "TATTIES" so that when I click on it the content of the field "TATTIES" is loaded into the field "BigGUFF" . . .
Re: Spotting a hyperlink?
Posted: Sun May 11, 2025 8:43 pm
by SWEdeAndy
The styling handler:
Code: Select all
command processLinks pFieldToProcess,pWordToLinkStyle
set the textStyle of word 1 to -1 of field pFieldToProcess to empty
put field pFieldToProcess into tText
lock screen
put 0 into tStartSearchAt
set the wholeMatches to true
repeat
put tokenOffset(pWordToLinkStyle, tText, tStartSearchAt) into tWordNum
if tWordNum = 0 then
exit repeat
end if
add tStartSearchAt to tWordNum
set the textStyle of word tWordNum of field pFieldToProcess to link
put tWordNum into tStartSearchAt
end repeat
unlock screen
end processLinks
Call it with e.g.
Code: Select all
on mouseUp
processLinks "BigGUFF","potatoes"
end mouseUp
In the field script:
Code: Select all
on linkClicked pLink
if pLink is among the words of the text of me then
answer pLink ## Insert whatever you really want it to do
end if
end linkClicked
Re: Spotting a hyperlink?
Posted: Sun May 11, 2025 8:44 pm
by FourthWorld
See the linkText property, and the linkClicked message to handle it.