use-livecode Digest, Vol 172, Issue 22

Brian Milby brian at milby7.com
Wed Jan 10 23:48:28 EST 2018


You may be able to simplify it to this:

*on* stripClipboard

*local* tData

*lock* the clipboard

*put* the rawClipboardData["public.utf8-plain-text"] into tData

*set* the rawClipboardData to empty

*set* the rawClipboardData["public.utf8-plain-text"] to tData

*unlock* the clipboard

*end* stripClipboard


Here is the same thing pasted after calling that handler:

on stripClipboard
   local tData
   lock the clipboard
   put the rawClipboardData["public.utf8-plain-text"] into tData
   set the rawClipboardData to empty
   set the rawClipboardData["public.utf8-plain-text"] to tData
   unlock the clipboard
end stripClipboard


I'm not sure how much will come through the list server, but the first
version had colors and looks double spaced (but it is actually paragraph
html tags causing the extra space).  The indents were missing.  The second
one is plain text without any extra space and indents were preserved.  I
selected the script from the LC SE and used cmd-C to copy.  I then used
cmd-V to paste it at the top.  I then went to LC and called the handler.
Next I used cmd-V to paste it the second time.  I'm using Gmail in Chrome
to draft the email.  The code is from LC 9 DP 11 running on Sierra.

I think that the problem is that the clipboard is getting filled with many
different versions of the same text.  Some applications are better about
selecting the best version to paste than others.  The original solution and
mine above essentially force the clipboard to only contain a single version
of the data in our chosen format.

Here's your function modified to use the same principle.  To test, I pasted
the code into the field (so it shows formatted with coloring).  I then
clicked the button and pasted into this email.  I only tested on Mac though.

on mouseUp
   local tClip, tRawType

   if the platform is "MacOS" then
      put "public.utf8-plain-text" into tRawType   -- OSX
   else if the platform is "Linux" then
      put "text/plain;charset=utf-8" into tRawType -- Linux
   else if the platform contains "Win" then
      put "CF_UNICODE" into tRawType -- Windows
   end if

   put fld "myField" into tClip
   lock the clipBoard
   set the ClipboardData to tClip
   put the rawClipboardData[tRawType] into tClip
   set the rawClipboardData to empty
   set the rawClipboardData[tRawType] to tClip
   unlock the clipBoard
end mouseUp

Cheers,
Brian



More information about the use-livecode mailing list