Stripping styling from the clipboard...

Paul Dupuis paul at researchware.com
Sat Jun 23 16:07:24 EDT 2018


Thank you for this.

However, it appears my problem is not with converting the clipboard from
styled text to plain text, but with the "pasteKey" message.

In LC9.0.0 under Windows 8.1, I create a new text stack and add and
empty field and place the following handler in EITHER the card or stack
script

on pasteKey
  makeClipboardPlainText
  paste
end pasteKey

on makeClipboardPlainText
   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_UNICODETEXT" into tRawType -- Windows
   end if
  
   lock the clipBoard
   put the rawClipboardData[tRawType] into tClip
   set the rawClipboardData to empty
   set the rawClipboardData[tRawType] to tClip
   unlock the clipBoard
end makeClipboardPlainText

And set a break point on the call to makeClipboardPlainText instruction.
I then switch to another applications with styled text, select the text
copy it to the clipboard, return for LC with the insertion point in the
field and press Control-V.

RESULT: the breakpoint is never triggered and styled text is pasted into
the field.

If I just have a pasteKey handler with a beep (or anything else) as the
sole instruction, the same result, the breakpoint is never triggered.
The pasteKey message appears broken under both Windows and OSX (tested
under 10.9.5) in LC9.0.0? Can anyone confirm this bug?


On 6/23/2018 1:23 PM, Brian Milby wrote:
> _https://github.com/bwmilby/lc-misc/blob/master/ClipboardHelper/clipboardhelper.livecodescript_
>
> Check out this handler. I can answer questions about it this evening
> if needed.
> On Jun 23, 2018, 9:18 AM -0500, Paul Dupuis via use-livecode
> <use-livecode at lists.runrev.com>, wrote:
>> Using LC9, I want to add a "paste without formatting" (as seen in may
>> browser edit menus) command and I can't see to figure out how to do it.
>>
>> My most recent attempt of many still pastes formatted text (with
>> underlining, bolding, italics, fonts, colors, etc. in place)
>>
>> *on*pasteKey *-- remove formatting*
>> *if* theclipboardData["text"] isnotempty*then*
>> *set*thetextofthetemplateFieldtoclipboardData["text"]
>> *set*theclipboardDatatoempty
>> *set*theclipboardData["text"] totheplaintextofthetemplateField
>> *end* *if*
>> *paste*
>> *end*pasteKey
>>
>> Maybe I just haven't had enough Caffeine yet?
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode






More information about the Use-livecode mailing list