Web links from scrolling field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Web links from scrolling field?
Hi there,
How do I create a link to a website from text in a scrolling field?
I have a body of text in a scrolling field on my card and I want to have a link from the text to a web page - just like if it were a Word doc... you know, blue underlined text = link.
If I copy and paste the text from a Word doc into the appropriate field in the object inspector, the text looks right - complete with blue underlined text, but how do I activate it?
Any help greatly appreciated.
Cheers,
P
How do I create a link to a website from text in a scrolling field?
I have a body of text in a scrolling field on my card and I want to have a link from the text to a web page - just like if it were a Word doc... you know, blue underlined text = link.
If I copy and paste the text from a Word doc into the appropriate field in the object inspector, the text looks right - complete with blue underlined text, but how do I activate it?
Any help greatly appreciated.
Cheers,
P
Re: Web links from scrolling field?
Hi Peter,
pasting from Word will only give you the right look but not the functionality!
You need to select the text that you want to make a link from and set its text-style to "link".
Then you will have to write a little script for that field like this:
See "linkClicked" in the docs (Dictionary) for more info.
Best
Klaus
pasting from Word will only give you the right look but not the functionality!

You need to select the text that you want to make a link from and set its text-style to "link".
Then you will have to write a little script for that field like this:
Code: Select all
on linkClicked tLink
launch url tLink
end linkClicked
Best
Klaus
Re: Web links from scrolling field?
Thanks Klaus - I'll give it a try...
Re: Web links from scrolling field?
I managed to get it working by setting the text-style of a line in the text to "link"You need to select the text that you want to make a link from and set its text-style to "link".
Eg:- set textstyle of line 13 in field…
But this is a bit cumbersome for my application. I have a couple of paragraphs of text with some (4 or 5) url addresses scattered in the text.
Is there some way of selecting the url addresses only? Some way of searching for them and setting them to "link" without me specifying exactly where they are as per the way I've done it above?
Any ideas?
P
Re: Web links from scrolling field?
Hi Petra,
of course you can (and will have to) write a little script to do this!
You could loop through all words!
(http/www.blablal.com/url1.html IS fortunately a word for Rev
)
So you could do something like this (not tested, but you get the picture)
Or replace WORD(S) with LINE(S), if the urls are in a line each.
Best
Klaus
of course you can (and will have to) write a little script to do this!
You could loop through all words!
(http/www.blablal.com/url1.html IS fortunately a word for Rev

So you could do something like this (not tested, but you get the picture)
Code: Select all
...
repeat with i = 1 to the num of words of fld "xyz"
if word i of fld "xyz" starts with "http://" then
set the textstyle of word i of fld "xyz" to link
end if
end repeat
...
Best
Klaus
Re: Web links from scrolling field?
Hi Klaus,

regards
Bernd
????Hi Petra

regards
Bernd
Re: Web links from scrolling field?
Oopsie, Freud'sche Fehlleistung/Freudian slip, should of course read "Peter" 

Re: Web links from scrolling field?
Great! With a little tweaking I got it to work - thanks heaps Klaus!You could loop through all words!
Now I am trying to get the curser to change to a hand when over the link. I can do it with buttons, but how to do it over a text link?
p.s. Klaus - no worries about the Freud'sche Fehlleistung
Re: Web links from scrolling field?
I'm working on something like this...
Am I close??
Code: Select all
on mouseenter Tword
if Tword is linktext then
set the cursor to hand
end if
end mouseenter Tword
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Web links from scrolling field?
Try this script in your field:
Whenever you move the mouse, it checks if there is text under the mouse, and if its text style contains "link" (that way, it also works if you set it to bold and italic, to name just two styles, in addition to link); and if so, it changes the cursor; if not, it unlocks the cursor.
HTH,
Jan Schenkel.
Code: Select all
on mouseMove
if the mouseChunk is not empty and the textStyle of the mouseChar contains "link" then
lock cursor
set the cursor to hand
else
unlock cursor
end if
end mouseMove
on mouseLeave
unlock cursor
end mouseLeave
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: Web links from scrolling field?
That's fantastic. I got it working - thank you so much Jan!
P
P
Re: Web links from scrolling field?
Hi all,
If I'm not mistaken, there may be a typo in Jan's elegant script, with "mouseChar" intended to be "mouseCharChunk" or, as an alternative, "mouseChunk", which might confuse future readers of this thread.
Regards,
Michael
If I'm not mistaken, there may be a typo in Jan's elegant script, with "mouseChar" intended to be "mouseCharChunk" or, as an alternative, "mouseChunk", which might confuse future readers of this thread.
Regards,
Michael
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Web links from scrolling field?
Michael is absolutely right - seems I hadn't pasted the final version that worked in my test stack. It was pretty close, but the correct script is:
Jan Schenkel.
Code: Select all
on mouseMove
if the mouseChunk is not empty and the textStyle of the mouseChunk contains "link" then
lock cursor
set the cursor to hand
else
unlock cursor
end if
end mouseMove
on mouseLeave
unlock cursor
end mouseLeave
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com