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" . . .
Spotting a hyperlink?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
richmond62
- Livecode Opensource Backer

- Posts: 10223
- Joined: Fri Feb 19, 2010 10:17 am
Re: Spotting a hyperlink?
The styling handler:
Call it with e.g.
In the field script:
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 processLinksCode: Select all
on mouseUp
processLinks "BigGUFF","potatoes"
end mouseUpCode: 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 linkClickedAndreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
(WIS_WebDeployHelper, WIS_ScriptDependencies, WIS_BrowserAnimation)
WhenInSpace: https://wheninspace.com
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10066
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Spotting a hyperlink?
See the linkText property, and the linkClicked message to handle it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn