Text behaving as link

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Text behaving as link

Post by mtecedor » Thu Jan 21, 2010 5:51 pm

Hi again,

I have a text field and I want several words to behave like links that redirect end users to other cards in the stack. I looked in the dictionary and the user guide, but I could not figure out the way to do it.

Any ideas?

Thanks,

Marta

massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Re: Text behaving as link

Post by massung » Thu Jan 21, 2010 6:34 pm

Example:

1. Create text field named "test"
2. Edit the contents to be "one two three"
3. Set the Locked Text of the field to be true
4. Open the MessageBox and do the following:
4a. set the textStyle of word 1 of fld "test" to "link"
4b. set the textStyle of word 2 of fld "test" to "link"
4c. set the textStyle of word 3 of fld "test" to "link"
5. Open the script for the field and add the following script:

Code: Select all

on linkClicked pLinkName
  answer pLinkName
end linkClicked
Hope this helps!

Jeff M.

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Re: Text behaving as link

Post by mtecedor » Mon Jan 25, 2010 2:08 am

Thanks a lot Jeff.

That worked. I also found the "link" command under "Text" (Dah!) What I dont like very much is that I cannot change the color when the user passes the mouse over (I am creating a sitemap), so I may have to go with invisible buttons, which seems to me much more time consuming option.

Marta

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Text behaving as link

Post by sturgis » Mon Jan 25, 2010 3:14 am

The code is a bit ugly, but if you put the following script in your card or stack script it should do the mouse over hilite you want

Code: Select all

on mouseMove -- highlight grouped text
   local tMouseChunk
   global tLastChunk
   put the mouseChunk into tMouseChunk
   if tMouseChunk <> tLastChunk  then
      if tLastChunk is not empty then 
         set the textColor of tLastChunk to empty
         put empty into tLastChunk
      end if
      if the mouseChunk is not empty and "link" is among the items of the textStyle of the mouseChunk then 
         set the textColor of tMouseChunk to "red"
         put tMouseChunk into tLastChunk
      end if
   end if
end mouseMove

Post Reply