Is there an easy way to create a hypertext in a scrollview? I know you can create a blue text object and put a touch listener on it with a system.openUrl call in there. But I think the touch functions of the scrollview might screw with that a bit. Is there a simple built-in function for hypertext? It seems like something that would be commonly used.
It turned out to be pretty easy. The only catch is that the hyperlink needs to be everything on an entire line or the coding would be a bit more complicated. I just added a few lines to the util.lua file that’s needed to run the scrollview. I also added a couple lines at the end to give it retina display text.
This is lines 87-111 of my version of util.lua
[lua] while i <= #arr do
local t = display.newText( arr[i], 0, 0, font, size )
–the following 13 lines were added by Matt at W2MD to give it hypertext capabilities on the portion “ilovecorona.com.”
if arr[i] == “ilovecorona.com” then
–changing to blue color
t:setTextColor( 0,0,255)
–setting touch listener to call up a website
local function openWebsite()
print(“getting touched”)
system.openURL(“http://www.ilovecorona.com”)
end
–the following two lines were added by Matt at W2MD to give it retina display
t.size = t.size * 2
t:scale(.5,.5)
[import]uid: 10211 topic_id: 9906 reply_id: 36132[/import]
This is great. I am trying to get to paste a hyperlink hand have it automatically saved as a hyperlink. I will see if this works. Did you ever solve the line issue?
No, I never worked it out. In my case it was completely unnecessary. All I did was put an “\n” right before the link in my string of text.
But I imagine you could do it without that by splitting the string into two or three parts and adjusting their x locations based on their length and respective locations on the line. [import]uid: 10211 topic_id: 9906 reply_id: 36384[/import]