formattedText to clipboard

J. Landman Gay jacque at hyperactivesw.com
Sat Nov 29 14:26:38 EST 2008


Mark Swindell wrote:
> Via a button, how can I capture the formatted text of a field and put it 
> into the clipboard so that it can then be pasted with formatting intact 
> into a word processor??
> 
> "Set the clipboardData to field x", puts the text but without formatting.
> 
> "Set the clipboardData to the htmlText of field x" puts the text plus 
> all the tags.
> 
> "Set the clipboardData to the rtfText of field x" puts the text plus all 
> the tags.
> 
> But if I manually select within the field, copy it, and then paste it 
> directly into Pages or Word, I get the formatted text (with some 
> glitches, but essentially ok for my purposes).
>

The clipboardData is an array. If you don't specify a key, "text" is 
assumed. So "set the clipboardData to field x" will fill the "text" key 
of the array. If you want to use other formats, use the appropriate key:

set the clipboardData["html"] to the htmlText of fld x
set the clipboardData["rtf"] to the rtfText of fld x
set the clipboardData["text"] to fld x

See the clipboardData entry in the dictionary for more keys. If you want 
to fill all keys at once automatically, you can use the ancient 
technique we had to use before the clipboardData was invented:

lock screen
select text of fld x
copy
select empty
unlock screen

This simulates a manual copy. It's very fast and often you don't even 
need to bother locking the screen because it happens so quickly you 
can't see the selection.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list