dynamically adding links with textStyle..
Curt Ford
cford at sc.edu
Wed Apr 4 16:26:23 EDT 2007
Thanks, Devin, I had been making this much harder than necessary,
worrying about whether I'd need to manipulate HTML or Unicode
directly if the selectedText was in Russian, but this works fine now
for setting a link, regardless of language:
on mouseUp
--save the selection before the 'ask..' makes it go away
put the selectedChunk into tSelection
--tSelection will now contain something like "char 1 to 4 of fld 1"
ask "Please enter a link:"
put it into tLink
select tSelection
set the linkText of the selectedText to tLink
set the textStyle of the selectedText to "link"
put the HTMLText of fld "source" into fld "resultHTML"
end mouseUp
To let the user edit an existing link, this works well too:
on mouseUp
--save the selection and its linkText before the 'ask..' makes it
go away
put the selectedChunk into tSelection
put the linkText of the selectedChunk into tOldLink
ask "Please edit the link:" with tOldLink
put it into tNewLink
--reselect what was selected before
select tSelection
set the linkText of the selectedText to tNewLink
set the textStyle of the selectedText to "link"
put the HTMLText of fld "source" into fld "resultHTML"
end mouseUp
..where the last lines are just a check to see what I end up with.
Thanks!
-Curt
Dr. Curtis Ford
Instructor of Russian and Linguistics
Dept of Languages, Literatures and Cultures
University of South Carolina
More information about the use-livecode
mailing list