Manipulating PLAIN text on the clipboard (trying again)

Ken Ray kray at sonsothunder.com
Sun Mar 14 23:03:19 EST 2004


Jonathan,

In order to keep the text font, style, etc. information, you need to
manipulate the clipboardData["html"], not the clipboardData["text"].

(Note: For those of you who get list mail in HTML, I'm wrapping the rest
in PRE tags so it will display properly.)

<PRE>
However in your case, you need to be a little careful. When converting
the clipboard to html, Rev adds a <p> to the beginning and a </p> to the
end, so if you copied "To be sure" from Word (set in Times 12 black),
the clipboardData["html"] looks like this:

  <p><font face="Times" size="12" color="#000000">To be sure</font></p>

So in order to get it to show "To be sure To be sure", you'd need to
strip the <p> tags from the first instance (they're not really needed
anyway). So your code would be (watch word wrapping):

on mouseUp
  put the clipboardData["html"] into temp
  -- check, just in case
  if char 1 to 3 of temp = "<p>" then delete char 1 to 3 of temp
  if char -4 to -1 of temp = "</p>" then delete char -4 to -1 of temp
  set the clipboardData["html"] to temp && temp
end mouseUp

This would end up with the following being on the clipboard:

  <p><font face="Times" size="12" color="#000000">To be sure</font>
<font face="Times" size="12" color="#000000">To be sure</font></p>

Which gives you the proper end product. Just keep in mind that if you
need to manipulate the text in the clipboard, do it in HTML in order to
keep the font, size, style, etc.

HTH,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com



> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of 
> JonathanC at ag.nsw.gov.au
> Sent: Sunday, March 14, 2004 8:23 PM
> To: use-revolution at lists.runrev.com
> Subject: Manipulating PLAIN text on the clipboard (trying again)
> 
> 
> Hi. About a week ago I asked a question about plain text on 
> the clipboard. 
> I had one reply (from Jacque - thanks) but the suggestion, 
> while helpful, 
> didn't solve the problem. I wrote this back to the list but 
> it seems to 
> have been lost in the mountains of other list emails. 
> (Incidentally, does 
> anyone else feel a bit overwhelmed by the number of 
> use-revolution emails 
> that arrive each day? :-) ).
> 
> So, I will try to restate the problem in its simplest terms:
> 
> Try this test:
> 1. Create a button ("Duplicate") with the following script:
> 
> on mouseUp 
>   put the clipboardData["text"] into temp
>   set the clipboardData["text"] to temp && temp
> end mouseUp
> 
> 2. Create a new word processor document.
> 3. Write a few words and set them in a font OTHER THAN Lucida 
> Grande. 4. Copy the text. 5. Switch to Rev and click the 
> "Duplicate" button. 6. Switch back to the document and paste. 
> 7. The text should be duplicated (i.e. "to be sure" becomes 
> "to be sure to 
> be sure" - Happy St Patrick's Day by the way!) in the same 
> font, size and 
> style as the original text.
> On my system* the pasted text ALWAYS ends up as Lucida Grande, 11 pt, 
> plain.
> (* Rev 2.1.2, Mac OS X 10.2.8, PowerBook G4 Titanium)
> 
> [I've even put a test stack on the web to save you having to 
> create your 
> own: 
> http://www.artgallery.nsw.gov.au/sub/test/clipboard_test_rev.s
it ]

Do you get the same result? If so, what SHOULD the script be to produce 
the desired result?

Regards,
Jonathan

Jonathan Cooper
Manager of Information / Website
Art Gallery of New South Wales
Sydney, Australia
http://www.artgallery.nsw.gov.au
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list