Visited Property and linkVisitedColor

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
deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm

Visited Property and linkVisitedColor

Post by deeverd » Sun Jul 05, 2015 12:18 am

Hello Forum,

Yep, I know that this is about as much of a noob question that could possibly be asked, but it's something I don't know how to do despite the user manual, dictionary, or forum posts...

What is the script and where does one place it to cause a visited link to change color?

I've seen the documentation on the "visited" property, linkVisitedColor, etc., and I've even found where one can find "Colors & Patters" in the Stack Property Inspector where the link and normal commands are located, but I have been unsuccessful in getting this basic function to work.

In case there's any question, my links work fine in a scrolling field, and I know that links are a text style and set as such. Also, as is supposed to happen, my links are blue and underlined and the whole works after setting them up as links. But how does the program know to turn them red when they are clicked on and purple once they are visited? Is that script placed in the field with the links or in the card or in the stack? Is it part of an if-then-else statement?

I could certainly use some very basic help here.

Thanks so much in advance,
deeverd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Visited Property and linkVisitedColor

Post by dunbarx » Sun Jul 05, 2015 3:09 am

Hi,

I don't use these at all, but you already seem to "know" the answers. It means setting properties based on user actions.

Can you write a handler to set the clickText to red? And if so, is it necessary to use the "visited" property at all?

As for where an appropriate place for such handlers to reside, the question to ask it whether there are many fields with this sort of requirement. If not, the field is where i would put them. If so, the card, and "the target" is your friend here.

But am I getting your question at all?

Craig Newman

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm

Re: Visited Property and linkVisitedColor

Post by deeverd » Sun Jul 05, 2015 4:44 pm

Hi Craig,

Thanks. I see that I can edit the script behind the field with a line like this one:

Code: Select all

if the clickText contains thisParticularLink then
set the foregroundColor of the clickText to "81,24,128"
end if
The only problem I see in this respect, by not understanding how to use the "visited" and "linkVisitedColor," is that such code keeps the clickText that color, which means it won't change back to its underline blue default when the card is closed and reopened.

There's also the issue that the the links are in a lengthy document where a number of the subheads are text with color.

If using this method, how could you get just the visited links (and none of the other text) to return to their default blue underline when the cards close?

Cheers,
Allen

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Visited Property and linkVisitedColor

Post by jacque » Sun Jul 05, 2015 7:48 pm

There is no script required to manage links in a field, the LC engine does that for you. All you need to do is set the style of the text to "link" and the engine will recognize it. You can control the colors that are displayed for the diferent statuses by setting the linkVisitedColor, etc. but you don't need to do anything else.

To reset the link to unvisited, set the "visited" property of the text chunk to false.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm

Re: Visited Property and linkVisitedColor

Post by deeverd » Sun Jul 05, 2015 9:12 pm

Hi Jacque,

Thanks for the reply. I had originally assumed that links visited would be automatically managed by the LC engine, which is probably why I have been so confused that they aren't working on my system. All my links were created by choosing the link textStyle and they work perfectly as hyperlinks, but they do not change color after being clicked.

My operating system is Windows 8.1, so perhaps there is an issue with that OS? (Besides all the other million issues with Windows 8.1). I'm also using LC 7.05.

I can manually cause the links to change color, as mentioned in the correspondence based on the suggestion by Craig, and just a few moments ago began using the following simple script to turn only the links back to blue when a card is closing or opening:

Code: Select all

if the textStyle of line tCounter of field "instructionsField" contains "link" then
         set the foregroundColor of line tCounter of field "instructionsField" to "0,0,238"
      end if
The only problem with this script is speed because the program has to check every line in the manual, rather than just those that have been visited, but it's the best I have for now.

Cheers,
Allen

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Visited Property and linkVisitedColor

Post by SparkOut » Sun Jul 05, 2015 9:35 pm

The engine *does* do this for you. You just need to

Code: Select all

set the linkVisitedColor to "red"
It's a global setting which will affect all links in the stack that have been (or will be) visited. The visited property of buttons or text chunks is reset when the stack closes (and is purged from memory).

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Visited Property and linkVisitedColor

Post by SparkOut » Sun Jul 05, 2015 9:55 pm

But it does appear testing with 7.04, 7.05 and 7.06rc1 that the visited property cannot be set. I can interrogate: the visited of line tLine of field "testField" which may return true or false appropriately, but I cannot: set the visited of line tLine of field "testField" to false
It throws an execution error, (Object: can't set this property)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Visited Property and linkVisitedColor

Post by jacque » Sun Jul 05, 2015 10:15 pm

SparkOut wrote:But it does appear testing with 7.04, 7.05 and 7.06rc1 that the visited property cannot be set. I can interrogate: the visited of line tLine of field "testField" which may return true or false appropriately, but I cannot: set the visited of line tLine of field "testField" to false
It throws an execution error, (Object: can't set this property)
You're right. It looks like a bug to me, it is possible to set a chunk's visited property in 6.7. Do you want to enter a report, or should I?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Visited Property and linkVisitedColor

Post by SparkOut » Sun Jul 05, 2015 10:19 pm

Bug 15577 filed (I was already on it)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Visited Property and linkVisitedColor

Post by jacque » Sun Jul 05, 2015 10:25 pm

SparkOut wrote:Bug 15577 filed (I was already on it)
You're a responsible citizen. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Visited Property and linkVisitedColor

Post by SparkOut » Sun Jul 05, 2015 10:30 pm

But growing old disgracefully 8)

Post Reply