Paul,
I tested a little bit more and this code works for me:
on mouseUp
   lock clipboard
   set the rawClipBoardData to empty
   set the rawClipboardData["CF_UNICODETEXT"] to textEncode(fld 1, "UTF-16" )
   unlock clipboard
end mouseUp

and the IDE doesn't crashes anymore.
BTW. The rawclipboarddata key is supposed to be ["CF_UNICODETEXT"] and not 
["CF_UNICODE"] as the docs say.

Thanks for your help
Tiemo


-----Ursprüngliche Nachricht-----
Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von 
Tiemo Hollmann TB via use-livecode
Gesendet: Mittwoch, 8. Februar 2017 09:33
An: 'How to use LiveCode' <use-livecode@lists.runrev.com>
Cc: Tiemo Hollmann TB <toolb...@kestner.de>
Betreff: AW: Different result in LC 6 to LC 8 when copying field text into 
Excel?

Hi Paul,

I test your approach, but when running the code in the DIE, LiveCode crashes 
immediatly. When debugging the code, it doesn't crashes, but stops at setting 
the rawclipboarddata with an error "clipboard is not locked".
This happens anyhow, if I am using "lock clipboard" or not.  I'll file it Tiemo

-----Ursprüngliche Nachricht-----
Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von 
Paul Hibbert via use-livecode
Gesendet: Dienstag, 7. Februar 2017 22:11
An: How to use LiveCode <use-livecode@lists.runrev.com>
Cc: Paul Hibbert <p...@livecode.org>
Betreff: Re: Different result in LC 6 to LC 8 when copying field text into 
Excel?

Tiemo,

I’m not sure if this will help because I’m testing on Mac, but I did a little 
bit of experimenting with the new ‘rawClipboardData’, it allows plain text to 
be copied out of LC, just to prove it, here’s a button script copied via my now 
modified Script Buddy plugin…

on mouseUp
   local tClip

   if the selectedText is empty then
      set the clipBoardData["text"] to fld “myTextField"
   else
      copy the selectedText
   end if
   
   if the altKey is down then -- Convert the clipBoard to plain text
      put the clipBoardData["text"] into tClip
      lock the clipBoard
      ## Use some code lifted from the LiveCode Dictionary…
      set the rawClipBoardData to empty -- Clear ALL ClipboardData
      if the platform is "Linux" then set the 
rawClipboardData["text/plain;charset=utf-8"] \
            to textEncode(tClip, "UTF-8" ) -- Linux
      if the platform is "Win32" then set the rawClipboardData["CF_UNICODE"] \
            to textEncode(tClip, "UTF-16" ) -- Windows
      if the platform is "MacOS" then set the 
rawClipboardData["public.utf8-plain-text"] \
            to textEncode(tClip, "UTF-8" ) -- OSX
      unlock the clipboard
   end if
end mouseUp

At last, no extra line spacing! :-)

Normally when I paste from LC into Mail I see extra line spacing, and I would 
have to copy and paste via a plain text editor to remove it. Emptying the 
clipBoard and setting the rawClipboardData as above seems to work, on Mac at 
least, hopefully it should work with Excel on Windows too.

Paul




> On Feb 3, 2017, at 6:25 AM, Tiemo Hollmann TB via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> Can anybody on Windows with LC 8 confirm this:
> 
> - create a new stack
> - create a scrolling list field
> - enter three lines of text, each with one word
> - enter into the message box: *set the clipboarddata["text"] to fld 1*
> - open MS Excel (in my case Windows 10, Excel 2013)
> - paste
> - see an extra empty line between each line of text
> 
> Pasted in a text editor there are no extra lines and up to LC 7 there 
> also was no extra line in Excel.
> 
> Can anybody confirm this behavior or even has an idea for a workaround?
> 
> Thanks
> Tiemo
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im 
> Auftrag von Tiemo Hollmann TB via use-livecode
> Gesendet: Donnerstag, 2. Februar 2017 12:13
> An: LiveCode User Liste senden <use-livecode@lists.runrev.com>
> Cc: Tiemo Hollmann TB <toolb...@kestner.de>
> Betreff: Different result in LC 6 to LC 8 when copying field text into 
> Excel?
> 
> Hello,
> 
> I have a standard scrolling list field with multiple lines of text. I 
> copy the text by:
> 
> *set the clipboarddata["text"] to fld "List"*
> 
> The User now can past the text into MS Excel on Windows. With LC 6 the 
> text was pasted into Excel line by line, as it showed up in LC. In LC
> 8.1.2 the text is pasted with an extra space line between each two lines.
> 
> I checked the line ends in both versions. There is only one "LF"
> (byteToNum=10) at the end of each line and it looks the same in both 
> versions.
> 
> What has changed in LC 8 to cause such a different behavior? Is this 
> again a Unicode thing what I don't understand? I already tried 
> different clipboarddata keys, without success.
> 
> It can't be an Excel option, because I tested it with the same Excel 
> version on the same machine.
> 
> Any idea, what has to be changed to get the same clipboard result as 
> in LC 6?
> 
> Thank you
> 
> Tiemo
> 
> 
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to