Hypertext

Jeanne A. E. DeVoto jeanne at runrev.com
Wed Jan 23 23:44:01 EST 2002


At 11:32 AM -0800 1/22/2002, Jean-Pierre Messier wrote:
>How I can make hypertext like the help in the revolution...
>
>Move the mouse and the selected text is yellow? I don't find the code 
>in the stack.

The  handlers that do this (revDocsHighlight and revDocsClearHighlight)
are actually in the documentation library. (Check the backScripts to find
this library and read the original script.) They're called from each stack's mouseMove, mouseLeave, mouseEnter handlers.

Here's a simplified version which you can place in a field's script. To make
a word or phrase "highlightable", change its text style to "link". You may
also want to turn off link coloring and link underlining in the Stack
Properties palette.

on mouseMove
  -- first unhighlight the "old" phrase if necessary
  if the storedHilitedChunk of this stack is not empty \
      and the storedHilitedChunk of this stack is not the mouseChunk then
    do "set the backgroundColor of" && (the storedHilitedChunk of this stack) && "to empty"
    set the storedHilitedChunk of this stack to empty
  end if
  if the mouseChunk is not empty and "link" is in the textStyle of the mouseChunk then
    set the storedHilitedChunk of this stack to the mouseChunk -- save for later unhighlighting
    set the backgroundColor of the mouseChunk to "yellow"
  end if
  pass mouseMove
end mouseMove

on mouseLeave
  if the storedHilitedChunk of this stack is not empty then
    do "set the backgroundColor of" && (the storedHilitedChunk of this stack) && "to empty"
    set the storedHilitedChunk of this stack to empty
  end if
  pass mouseLeave
end mouseLeave

Unlike the version in the docs library, this doesn't change the cursor, and it's
hardcoded to use yellow instead of a choice of colors the way the docs have.

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
http://www.runrev.com/
Runtime Revolution Limited - Power to the Developer!





More information about the use-livecode mailing list