Stripping styling from the clipboard...

Brian Milby brian at milby7.com
Sat Jun 23 17:38:08 EDT 2018


Nice catch Tore.

My original code was addressing a different couple of problems. The first was that when you attempted to populate the clipboard with plain text that LC would also put an HTML version on that would cause issues with paste in other apps. The second is designed to adjust the HTML that is put onto the clipboard to make it render better in other apps as rich text.

I didn’t initially realize that you were attempting to clean a clipboard originating outside of LC. You may want to put the keys of the raw clipboard and see if the system is placing something on there that you could use. Many apps will place several formats on the clipboard so that destination apps can choose the best version to use.

Thanks,
Brian
On Jun 23, 2018, 5:15 PM -0400, Tore Nilsen via use-livecode <use-livecode at lists.runrev.com>, wrote:
> From the dictionary:
>
> The LiveCode development environment traps the pasteKey message <>, unless "Suspend LiveCode UI" is turned on in the Development menu. This means that the pasteKeymessage <> is not received by a stack <> if it's running in the development environment <>.
>
> So if you are trying to do this in the IDE, then that may be the reason it will not work.
>
> Best regards
> Tore Nilsen
>
> > 23. jun. 2018 kl. 22:32 skrev Richmond Mathewson via use-livecode <use-livecode at lists.runrev.com>:
> >
> > Hey, Wow, it's the Richmond school of shovels and primitive stuff at its worst.
> >
> > If I have a field that conatins some styled text (let's call it "ff1"), and I want to shift it
> > with its styling removed into another field (let's call it "ff2") then this does the trick in a button:
> >
> > onmouseUp
> > gettheplainTextoffld "ff1"
> > putit intofld "ff2"
> > endmouseUp
> >
> > and that, oddly enough, might not be a bad place to get started.
> >
> > ALTHOUGH (ouch) this does NOT work:
> >
> > onpasteKey
> > gettheplainTextoftheclipboardData
> > putit intofld "ff2"
> > endpasteKey
> >
> > and this does not work:
> >
> > onpasteKey
> > puttheclipboardDataintofld "ff1"
> > send"mouseUp" tobtn "Button"
> > endpasteKey
> >
> > which would seem to suggest pasteKey is NOT trapping the paste signal at all.
> >
> > Richmond.
> >
> >
> > On 23/6/2018 5:15 pm, Paul Dupuis via use-livecode 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
> >
> > _______________________________________________
> > 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
>
> _______________________________________________
> 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