Hi Folks,
I am trying to use the following code in the "Link text rollover effect" in the LiveCode Lessons How To samples:
## first unhighlight the "old" phrase if necessary:
if storedHilitedChunk is not empty and storedHilitedChunk is not overChunk then
set the backgroundColor of storedHilitedChunk to empty
put empty into storedHilitedChunk
end if
## highlight if the text under the mouse is linked:
if overChunk is not empty then
if the textStyle of overChunk is "link" then
set the backgroundColor of overChunk to "yellow"
## saved for later unhighlighting
put overChunk into storedHilitedChunk
end if
end if
pass mouseMove
end mouseMove
but I am getting the following error:
field "Server Documents" execution error at line n/a (Chunk: error in object expression near storedHilitedChunk", char 1
and have not been able to find any reference to this error.
Any help would be greatly appreciated.
Thanks,
Daryl
MouseMove error
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: MouseMove error
Hi Daryl,
use the following code in a field that you named "text" in the Properties Inspector (without quotes)
You will notice that it is the same code as in the lesson EXCEPT that the lesson left out the declaration of the script local variable storedHilitedChunk. This is done on top of the script see the comment in the code in the first line.
By declaring a script local variable both handlers, the mouseMove handler and the mouseLeave handler have access to the variable storedHilitedChunk. As that was missing from the lesson it threw an error.
Now you paste or type some text into the field and use either in a button or from the message box. change the number 32 to a couple of instances of words in your text and they will appear underlined. Now move the mouse over the text and the underlined link style text hilites yellow.
Kind regards
Bernd
I attach the sample stack with above code as zip file
use the following code in a field that you named "text" in the Properties Inspector (without quotes)
Code: Select all
local storedHilitedChunk -- here the script local variable storedHilitedChunk is declared
on mouseMove
put the mouseChunk into overChunk
## first unhighlight the "old" phrase if necessary:
if storedHilitedChunk is not empty and storedHilitedChunk is not overChunk then
set the backgroundColor of storedHilitedChunk to empty
put empty into storedHilitedChunk
end if
## highlight if the text under the mouse is linked:
if overChunk is not empty then
if the textStyle of overChunk is "link" then
set the backgroundColor of overChunk to "yellow"
## saved for later unhighlighting
put overChunk into storedHilitedChunk
end if
end if
pass mouseMove
end mouseMove
on mouseLeave
## unhighlight any currently highlighted text:
if storedHilitedChunk is not empty then
set the backgroundColor of storedHilitedChunk to empty
put empty into storedHilitedChunk
end if
pass mouseLeave
end mouseLeave
By declaring a script local variable both handlers, the mouseMove handler and the mouseLeave handler have access to the variable storedHilitedChunk. As that was missing from the lesson it threw an error.
Now you paste or type some text into the field and use
Code: Select all
set the textStyle of word 32 of field "text" to link
Kind regards
Bernd
I attach the sample stack with above code as zip file
- Attachments
-
- hiliteLInkedText.livecode.zip
- (1.67 KiB) Downloaded 182 times
Re: MouseMove error
Hi Bernd,
Thanks for your reply, I appreciate it. I will study it and give it a try.
This forum awesome!
Best Regards,
Daryl
Thanks for your reply, I appreciate it. I will study it and give it a try.
This forum awesome!
Best Regards,
Daryl