styledtext, mixed content and clipboarddata

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bobcole
VIP Livecode Opensource Backer
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

Post by bobcole » Sun Sep 04, 2022 8:52 pm

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
StyledTextArray.livecode.zip
(1.64 KiB) Downloaded 62 times

stam
Posts: 2756
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: styledtext, mixed content and clipboarddata

Post by stam » Sun Sep 04, 2022 10:25 pm

bobcole wrote:
Sun Sep 04, 2022 8:52 pm
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

StyledTextArray.livecode.zip
Well Bob, that thickens the plot.
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

bobcole
VIP Livecode Opensource Backer
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

Post by bobcole » Mon Sep 05, 2022 9:57 pm

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.
(Must be correctly constructed as a LiveCode styledText array, see comments)
So, apparently the LiveCode has a specific styledText array. I assume that means it isn't necessarily supported by other applications.

Also, I saw this:
The engine flattens any nested numeric arrays within the tree
but I don't know if that is causing any problems with copy and paste operations.

Today, I had the novel idea of searching for "styled text" in the User Guide where I saw this:
LiveCode supports encoding and decoding styled text as HTML and RTF.
I conclude that some of the style information is lost when the using the clipboard to copy or paste styledText; and
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

rodneyt
Posts: 128
Joined: Wed Oct 17, 2018 7:32 am

Re: styledtext, mixed content and clipboarddata

Post by rodneyt » Tue Sep 06, 2022 9:36 am

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

stam
Posts: 2756
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: styledtext, mixed content and clipboarddata

Post by stam » Tue Sep 06, 2022 9:42 am

rodneyt wrote:
Tue Sep 06, 2022 9:36 am
Still doesnt resolve the issues identified in the thread, which may perhaps need to be filed as a bug report?

Rod
stam wrote:
Sun Sep 04, 2022 4:02 am
EDIT: I submitted a bug report for this here: https://quality.livecode.com/show_bug.cgi?id=23922

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9454
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: styledtext, mixed content and clipboarddata

Post by richmond62 » Tue Sep 06, 2022 11:35 am

SShot 2022-09-06 at 13.33.58.png
-
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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”