styledtext, mixed content and clipboarddata
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 136
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: styledtext, mixed content and clipboarddata
According to the Dictionary, the StyledText property is an array.
This little example stack gets the array of an example field and puts the array into a Tree View widget.
The widget allows us to see how the array is structured.
Perhaps the visual representation will help us decipher the problem and determine a solution.
FYI,
Bob
This little example stack gets the array of an example field and puts the array into a Tree View widget.
The widget allows us to see how the array is structured.
Perhaps the visual representation will help us decipher the problem and determine a solution.
FYI,
Bob
Re: styledtext, mixed content and clipboarddata
Well Bob, that thickens the plot.bobcole wrote: ↑Sun Sep 04, 2022 8:52 pmAccording to the Dictionary, the StyledText property is an array.
This little example stack gets the array of an example field and puts the array into a Tree View widget.
The widget allows us to see how the array is structured.
Perhaps the visual representation will help us decipher the problem and determine a solution.
FYI,
Bob
StyledTextArray.livecode.zip
I note the text in your stack is nicely spaced and weirdly everything works as expected.
However if you put a new field in it's place and just add text and style it (i.e. not nicely spaced), the fault i reported above still occurs.
I've modified the your stack:
- I've added a 'destination' field to which the styled text of the 'source' can either be pasted or target of a 'set' command
- added buttons to set the 'source' field to either your nicely 'spaced' or text that is 'native', ie just entered with no styling and then have the styles applied.
- I've also added a second tree widget to show what arrays the clipbardData["styledText"] holds
- And finally an option to paste text from source to destination or set the styledText of destination to the styledText of the source.
Weirdly:
If your text is set as source, it works beatifully
If instead the native text is set as source, it generates the same error as what i mentioned above.
Any ideas?
I wonder if text with no attributes or text set as 'plain' causes the issue as in your case, all text has some attribute (even the apparently unstyled text has the style of spaceBelow = 10)
- Attachments
-
- styledTextCopyIssue v2.livecode.zip
- (2.7 KiB) Downloaded 63 times
-
- VIP Livecode Opensource Backer
- Posts: 136
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: styledtext, mixed content and clipboarddata
Hmmm. I spend yesterday trying to understand why copying a field with styled text doesn't carry over the styles when pasted.
In the Dictionary, I saw this:
...the styled text.
Also, I saw this:
Today, I had the novel idea of searching for "styled text" in the User Guide where I saw this:
the htmlText or rtfText of a field would be better for copy and paste.
This still doesn't answer all of stam's valid points but at least, I hope, this provides some more insight.
Bob
In the Dictionary, I saw this:
...the styled text.
So, apparently the LiveCode has a specific styledText array. I assume that means it isn't necessarily supported by other applications.(Must be correctly constructed as a LiveCode styledText array, see comments)
Also, I saw this:
but I don't know if that is causing any problems with copy and paste operations.The engine flattens any nested numeric arrays within the tree
Today, I had the novel idea of searching for "styled text" in the User Guide where I saw this:
I conclude that some of the style information is lost when the using the clipboard to copy or paste styledText; andLiveCode supports encoding and decoding styled text as HTML and RTF.
the htmlText or rtfText of a field would be better for copy and paste.
This still doesn't answer all of stam's valid points but at least, I hope, this provides some more insight.
Bob
Re: styledtext, mixed content and clipboarddata
These are excellent points Bob. For my own purposes I have found rtftext works best. I think the Livecode dictionary should be updated to make it clear that for clipboard compatability when moving styled content between apps rtftext should be used by preference (along with summary of key points you raise above).
Still doesnt resolve the issues identified in the thread, which may perhaps need to be filed as a bug report?
Rod
Still doesnt resolve the issues identified in the thread, which may perhaps need to be filed as a bug report?
Rod
Re: styledtext, mixed content and clipboarddata
stam wrote: ↑Sun Sep 04, 2022 4:02 amEDIT: I submitted a bug report for this here: https://quality.livecode.com/show_bug.cgi?id=23922
-
- Livecode Opensource Backer
- Posts: 9454
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: styledtext, mixed content and clipboarddata
Still NBG for LibreOffice.
Code: Select all
on mouseUp
set the htmlText of fld "fTEXT" to the clipBoarddata["htmlText"]
end mouseUp
Code: Select all
on mouseUp
set the RTFtext of fld "fTEXT2" to the clipBoarddata["RTFtext"]
end mouseUp