copying and pasting from/to fields not working?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Ed_Ray
Posts: 83
Joined: Sun Jun 19, 2016 12:18 am

copying and pasting from/to fields not working?

Post by Ed_Ray » Wed Nov 30, 2016 1:27 am

I can usually copy/paste data from my input fields to any target document and I can usually copy/paste data from any source document to my input fields.

[A] Occasionally I can't seem to do this. Is there anything that would inadvertently prohibit such actions?

When I create an output results field I can't seem to copy/paste data from the field to any target document and I can't copy and paste data from a source document into my output results field. How can I make this happen?

Basically I want the user to be able to copy and paste portion of the results to any target document and I want the user to be able to annotate any useful reminder information onto the output/results field. These are typical things one can do with almost any windows app so this is not something that is that extraordinary.

[C] Lastly, does anyone know what the field property "sharedText" is used for? What does it actually do?

Thanks.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: copying and pasting from/to fields not working?

Post by dunbarx » Wed Nov 30, 2016 5:36 am

Hi.

All the things you speak of should be ordinary and unremarkable. Whether you simply copy/paste by user action, set/get the clipBoardData or whatever, these should be uneventful and, well, ordinary.

I am on a Mac, but I have not heard much chatter at all about the sort of stuff you seem to be dealing with.

As for the sharedText, check out the dictionary. Then make a new stack. Make two fields. Set the sharedText of one of them. Put some text into both. Group the two fields, and set the backgroundBehavior of the group to "true".

Now create a new card. The group will appear on the new card, but look at the text in the fields on that new card. Play around...

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: copying and pasting from/to fields not working?

Post by jacque » Wed Nov 30, 2016 6:24 pm

What is the target app you are pasting into? There are a few specific apps that don't accept the LiveCode clipboard. PowerPoint is one I know of and there's another I can't recall. There may be more. MS Word used to be one also but I believe it is fixed.

One workaround is to paste the text into a plain text editor, copy it there, and then paste into the target document. This isn't convenient but it works.

If you have a list of affected apps, a bug report about those might help the team solve the problem.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Ed_Ray
Posts: 83
Joined: Sun Jun 19, 2016 12:18 am

Re: copying and pasting from/to fields not working?

Post by Ed_Ray » Thu Dec 01, 2016 10:07 am

I tried copying and pasting from my results /output field into wordpad, notepad, notepad++ word for windows and none work.
So yes at this point I agree all these should work!

Is there some livecode clipboard setting that needs to be set for this to work?

Thanks

Ed_Ray
Posts: 83
Joined: Sun Jun 19, 2016 12:18 am

Re: copying and pasting from/to fields not working?

Post by Ed_Ray » Thu Dec 01, 2016 12:21 pm

The output/results field I am trying to cut and paste portions of is not pure text. It has styled text which I have previously "copied" directly (I assume bypassing the livecode clipboard) to other fields by stating: set the htmlText of field "Destination" to the htmlText of field "Source" and this had worked perfectly.

So is the issue one that you can't directly copy styled text into the clipboard?
I did not think so originally because when looking previously into the "clipboardData property" the dictionary clearly stated that:

The clipboardData is an array with one or more of the following elements:

text The text on the clipboard
***** HTML The styled text on the clipboard, in the same format as the htmlText *******
RTF The styled text on the clipboard, in the same format as the RTFText
Unicode The text on the clipboard, in the same format as the unicodeText
image The data of an image (in PNG format)
files The name and location of the file or files on the clipboard, one per line

So can someone please tell me what do I need to do with the clipboard so that I can copy a desired styled text portion of a field (not necessarily the entire field) into it for subsequent pasting into a document?

Thanks.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: copying and pasting from/to fields not working?

Post by dunbarx » Thu Dec 01, 2016 2:55 pm

Hi.

Try something like this:

Code: Select all

set the clipboardData["styledText"] to the styledText of yourSourceOfText
Unless there are other issues with certain programs, this should carry styled text to wherever you want to paste.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: copying and pasting from/to fields not working?

Post by jacque » Thu Dec 01, 2016 5:37 pm

Are you copying with the menu /keyboard shortcut or by script? If you are manually copying it should definitely work. If by script then you probably need to fill several elements of the array. For example, if you don't put anything into the text element then text editors won't have anything to paste.

When you do a manual copy, LC populates all appropriate elements at once.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Ed_Ray
Posts: 83
Joined: Sun Jun 19, 2016 12:18 am

Re: copying and pasting from/to fields not working?

Post by Ed_Ray » Fri Dec 02, 2016 9:29 am

Responding back to "dunbarx" comment:

[1]
Thanks for your response. I already tried that (set the clipboardData["styledText"] to the styledText of yourSourceOfText) but unfortunately my style text includes bolds, italics and backgound color (property "backgroundColor") for some of the words or lines.

No matter where it gets pasted wordpad, word for windows or even into an html file, the background colors for the words or lines are not kept and therefore not pasted at all or everything ends up just being bold with no background color or in the rare case the background color is even attempted to be pasted, it ends up with the background colors getting pasted in as black with the font in white definitely not what the user would want.

Can you give me what app you were able to paste successful keeping the bolds, italics and BACKGROUND COLORS intact?

[2]
Also as stated in my last post regarding the clipboardData property I never saw within my dictionary where "styledText" is even an element (only shows text, html, rtf, unicode, image and files so where did the ""styledText" element come from? Can't see it mentioned anywhere else.

Dictionary states:
Value:
The clipboardData is an array with one or more of the following elements:

text The text on the clipboard
HTML The styled text on the clipboard, in the same format as the htmlText
RTF The styled text on the clipboard, in the same format as the RTFText
Unicode The text on the clipboard, in the same format as the unicodeText
image The data of an image (in PNG format)
files The name and location of the file or files on the clipboard, one per line

[3]
Also previously attempting "set the clipboardData["htmlText"] to the htmlText of field "Source" did not work at all (nothing was copied) even though previously I had "copied" styletext from a source field to a destination field by stating:
set the htmlText of field "Destination" to the htmlText of field "Source". This had worked perfectly.

Any reason why ""set the clipboardData["htmlText"] to the htmlText of field "Source"" would not work and was "forced" to use ""styledText" instead of "htmlText" but "set the htmlText of field "Destination" to the htmlText of field "Source" worked perfectly?

Ed_Ray
Posts: 83
Joined: Sun Jun 19, 2016 12:18 am

Re: copying and pasting from/to fields not working?

Post by Ed_Ray » Fri Dec 02, 2016 9:57 am

Responding to Jacque.
Please see my response to "DunBarx".

I am using ctrl-c for copying and and ctrl-v for pasting. This is the standard manual keyboard short cut keys to use.
Just wondering why:

[1]just manually cutting (ctrl-c) from my output result field and doing nothing else (meaning not doing ANYTHING ELSE as in as in additional things to do as steps [2] and [3] below - from previous recommendations from other various folks) does not JUST work like 90% of all other windows apps do without needing any other remedial steps to bolster and help "nudge" its clipboard along to do the right things.

All other windows apps I tried to copy and paste styled text output results easily copied and pasted perfectly retaining ALL OF THE STYLED TEXT without doing anything else with the clipboard as should be the case.

So what's up with livecode needing so much additional instructions to the clipboards to get any of this to work. At this point in its existence, the livecode clipboard should be working like all the other windows clipboard functions right?......I just don't get it. This should be extremely straight forward but it isn't!

Thanks
==================================================================================
[2] "set the clipboardData["htmlText"] to the htmlText of yourSourceOfText) did not work - nothing was copied
[3] "set the clipboardData["styleText"] to the styleText of yourSourceOfText) worked in a limited manner. As stated to "dunbarx", the bold and italic were retained and replicated but no background color for specified words within a line was retained and replicated in the paste (via ctrl-v).

But again why do we need to do all this extra livecode clipboard nudging to get it to work when no other app under the sun requires anything like this for its clipboard to work?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: copying and pasting from/to fields not working?

Post by [-hh] » Fri Dec 02, 2016 10:07 am

You could use the rawClipboardData ( introduced in LC 8 ).

There is a great Clipboard stack for both, clipboardData and rawClipboardData, by Stephen Barncard.

You will find the link here (LC use-list):
http://lists.runrev.com/pipermail/use-l ... 32070.html
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10309
Joined: Wed May 06, 2009 2:28 pm

Re: copying and pasting from/to fields not working?

Post by dunbarx » Fri Dec 02, 2016 5:45 pm

Hmmm.

I made a field with a couple of lines of text. One line I made green, one line underlined, that sort of thing.

I used "[styledText]" (it is one of the examples in the dictionary) and pasted into textEdit and MS Word. Styles held in both apps.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: copying and pasting from/to fields not working?

Post by jacque » Fri Dec 02, 2016 9:03 pm

Using only keybord shortcuts or menu items, LC will always copy the styled text as well as the plain text and all the other relevant elements the clipboard can contain. You should not need to alter the clipboard array at all. Except for colors, you've already seen it works.

The receiving app is in control of what it displays. A plain text editor frequently will not accept styled text of any kind, only ascii. It doesn't matter if the clipboard contains styles, the text editor won't use them. I know of no editor (on Mac, anyway) that supports background colors the way LC uses them. Some may support colored text, but not background colors behind the text.

LC uses a tagging convention for background colors that is unrecognizable to most other apps. None of those will use the colors you see in LC. That is why it works to set one LC field to the htmlText of another -- they are both LC fields using the same tagging format. It fails in other apps because they don't understand, or will not accept, the tags that LC uses. Your best bet for transferring both styles and colors is html but the receiving app must recognize that and be able to work with it. If the receiving app expects only text, and you have put only htmlText into the clipboard but have not also filled the plain text element of the array, then the receiving app will not see any plain text in the clipboard and will do nothing. That's what you saw in your tests too. Note that I'm not talking about colored text, I mean the color fill behind the text that LC enables.

Basically I think you need to settle for styled text only, since LC's background colors aren't supported in any apps I know of. I know some apps support their own variants of background fills, but those are different from the character-based fills that LC can create. OF course, I can't know what every app does everywhere, so some may be able to work with character-based background fills but if you want to use those, you'd probably have to learn their file format and construct a clipboard translation to use that.

Have you ever seen WordPad, for example, use a background color fill?

If you find that the Windows clipboard doesn't behave as I described above, then you may have found a bug and should report it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Ed_Ray
Posts: 83
Joined: Sun Jun 19, 2016 12:18 am

Re: copying and pasting from/to fields not working?

Post by Ed_Ray » Wed Dec 07, 2016 10:14 am

For Jacque and dunbarx;
Sorry for not getting back sooner. I ran into some emergencies which required me to drop everything for 3-4 days.

Getting back to some of your helpful comments, on my particular results field which originally nothing could be copied from,I found out that if I use the IDE menu bar edit key (which states its the same as ctrl-c) I can actually copy things. If I use ctrl-c nothing copies. How about that for a measure of weirdness?

I checked my other output field which has EXACTLY the same property settings and it copies using BOTH methods.

So at this point since I am not getting any traction on resolving the non copy with ctrl-c issue and nobody has come up with a possible reason for this, I have come up with a real slick work around that works with a single line of code to make the copy work without having to use any of the following: the clipboard function (used to determine the type of info in the clipboard), the clipboardData property (used to get or change the data on the clipboard) and the selectedText function (used to determine what text is currently selected) since I need to selectively retain the styled text for SELECTED parts of the field not just the entire field.

I will post this solution and the solution to overcome the non Standardization issue that livecode has with background colors on words and lines on my next post hopefully within a couple of days once I write everything down and my ideas are not just floating in my head.

This other solution will not just cover the entire field being retained with its background colors, but even SELECTED parts of the field (much harder to do since its not just entire lines) with full background color retention when copied.

While I round up my ideas and put them on "paper" I still would like to get some answers on some of my previous questions that never got answered which may help me make the up coming solutions better.

These were originally directed to "dunbarx" but "jacque" can chime in if he knows something
[1]Any reason why ""set the clipboardData["htmlText"] to the htmlText of field "Source"" would not work and was "forced" to use "styledText" instead of "htmlText" which parcially worked except for the non colors on the backgrounds, but "set the htmlText of field "Destination" to the htmlText of field "Source" works perfectly everytime?

[2] "Dunbarx" stated: "I made a field with a couple of lines of text. One line I made green, one line underlined, that sort of thing".

The issue is BACKGROUND colors on words and lines etc not just foreground font colors or underlines.
Have you been able to copy parts of a field or an entire field using ctrl-v directly from a field onto a desktop or online word processing like word for windows or google docs retaining full colors on all the words or lines with BACKGROUND colors not just color underlines or foreground text font colors.

I have yet to see anybody do this successfully on MAC or windows because of what jacques correctly stated: the non standardization that livecode has put into its background color renditions.

Thanks for all your help.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: copying and pasting from/to fields not working?

Post by jacque » Wed Dec 07, 2016 8:29 pm

These were originally directed to "dunbarx" but "jacque" can chime in if he knows something
[1]Any reason why ""set the clipboardData["htmlText"] to the htmlText of field "Source"" would not work and was "forced" to use "styledText" instead of "htmlText" which parcially worked except for the non colors on the backgrounds, but "set the htmlText of field "Destination" to the htmlText of field "Source" works perfectly everytime?
Well, you already answered that actually. HTML tags for background colors are stored in a LC-specific way, so of course it will work within LC fields but not in other apps.

BTW, I'm a "she". :) It doesn't look like it, but my name is pronounced "Jackie". When I was 14 I decided I hated the diminutive and changed the spelling.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: copying and pasting from/to fields not working?

Post by FourthWorld » Wed Dec 07, 2016 9:01 pm

Ed_Ray wrote:The issue is BACKGROUND colors on words and lines etc not just foreground font colors or underlines.
If:
a) all other expected text attributes show up when pasted (font, size, text color, bold, italic, etc.)
b) you're pasting into a program not made with LC
c) when pasting into LC even backgroundColor works,

Then:
It may be that backgroundColor is not among the attributes supported in the generic OS clipboard.

To verify that would require going through the relevant OS APIs to determine the scope of what's supported.

But if C is not true then it may be a bug in LC rather than a limitation of the host OS.

This has been a long thread and I haven't read every word here, so forgive me if I've missed something important.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply