hypertext

Michael Crawford michael.crawford at stonebow.otago.ac.nz
Wed Apr 10 18:15:01 EDT 2002


MMessieh at aol.com wrote:
>
> Need help writing a script for a hypertext link in a field that is not
> locked.
>
> I want to paste URLs in an unlocked field and open the URL when the hypertext
> is selected.or whatever..the field must be unlocked to accept notes as well.


Andu wrote:

on selectionChanged
put the clickText
end selectionChanged

Remember to make the text style of your URLs to "Link" as well. Then you
will get the entire URL when it is clicked on rather than just the
individual word.


on selectionChanged
if the clickText <> empty then
  put the clickText into tURL
  put the clickChunk into tChunk
  if the textStyle of tChunk contains "link" then -- it is a link
    put "User Clicked on a URL:"&&tURL
goURL tURL
  else
    Put "User just clicked on normal text"
  end if
end if
end selectionChanged

And since I just happened to have the stack open that does the Browser
launch thing. (Thanks to Shari  for this script.)

on goURL tURL
  if tURL contains "@" then put "mailto:" before tURL
  if (the platform) is "MacOS" then
    get the systemversion
    set the itemdel to "."
    if item 1 of it >= 10 then # OS X
      put "open location" && quote & tURL & quote into s
      do s as AppleScript
    else # MacOS
      send tUrl to program "Finder" with "GURLGURL"
    end if
  else if (the platform) is "Win32" then
    local intApp
    local EXE_off
    put
queryRegistry("hkey_local_machine\software\classes\http\shell\open\command\") in
to intApp
    if char 1 of intApp is quote then clear char 1 of intApp  # strip
leading quote
    put offset("EXE",intApp) into EXE_off
    put char 1 to (EXE_off+2) of intApp into intApp
    launch tURL with intApp
  end if
end goURL


Michael





More information about the metacard mailing list