differentiate between links in text?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

differentiate between links in text?

Post by peter.s » Sat Oct 09, 2010 7:07 am

Hi,

I can't figure out how to have my mouseMove message differentiate between links.

I have been successful in creating a link from a word in a field of text (thanks to visitors to my previous post), and I have even figured out how specify the destination of each link; ie: Link1 goes to Card 1 and Link2 goes to Card 2. See code below.

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
      show group "InfoCard"
   else
      unlock cursor
    end if
end mouseMove

on mouseLeave
   unlock cursor
      hide group "InfoCard"
end mouseLeave

on linkClicked theText
   if theText is "backwards" then go to card 1
   if theText is "forwards" then go to card 2
end linkClicked
As you can see above, I need to display an "information card" when the mouse hovers over the links. If I have two or more different links in my text field, then I need different information cards to display depending on the link in question. I can make my information card display with All links (as above), but can't figure out how to make it specify one from another.

Any ideas?

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Re: differentiate between links in text?

Post by Regulae » Sat Oct 09, 2010 3:44 pm

Hi Peter,

I've prepared a small stack which uses the mouseText property to determine what to display when the mouse is over different links. My mouseMove handler is arranged slightly differently from the one you're using, but the effect is essentially the same. For my example I just used different fields to display the "message text" associated with each link, rather than grouping them, which could be done if desired.

Regards,
Michael
Attachments
LinkTextTest.zip
(3.35 KiB) Downloaded 252 times

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Re: differentiate between links in text?

Post by peter.s » Sun Oct 10, 2010 4:12 am

Hi Michael,

Thank you once again for going the extra mile and providing something that is not only the solution, but also useful as a tutorial! I learnt more from that stack than what I would have (already have) learnt from a few hours of trial and error.

As it turned out, I was already pretty close with my test scripts. I was trying to use the mouseText property, but didn't understand the basics of the If control... I do now though! :)

Cheers,

Peter

Post Reply