creating hypertext in scrollView

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.

-Matt
W2MD

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    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
                        
                        t:addEventListener("touch", openWebsite)
                else
                        t:setTextColor( color[1], color[2], color[3] )
                end
                t.x = math.floor(t.width/2)
                t.y = math.floor((size*1.3)*(i-1))
                
                --the following two lines were added by Matt at W2MD to give it retina display
                t.size = t.size * 2
                t:scale(.5,.5)

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?

Thanks

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.

views:1499 update:2011/10/1 9:04:19
corona forums © 2003-2011