How to calibrate the pasteboard so that references are pasted with style and value
When you copy or cut a piece of styled text in 4D, both the RTF and HTML renderings are added to the pasteboard.
When the source text is an expression or reference, the HTML version does not contain any visible text, either as values or as references.
The references are stored as attributes. For example, public.html
may look like this:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p style="white-space:pre-wrap;border-width:2pt;font-size:12pt;margin:0pt;padding:0pt;font-family:'Times New Roman'">
<span> </span><!--notice the empty span-->
</p>
</body>
</html>
There is also a com.4d.private.text.span
and com.4d.private.text.spanext
, where the references are stored as styles:
<span style="-d4-ref:'[Table_1:1]Field_2:2'"> </span>
Still, the text span has no content, so the pasted content will display as empty.
public.rtf
, by contrast, contains the text as WYSIWIG.
However, most external apps will prefer HTML over RTF, which mwans the pasted text would be empty.
Before pasting to an external app, the use would likely move 4D to the background. So there is a chance to perform some tricks in the On System Event database method.
The goal is to remove public.html
from the list of pasteboard data types.
You can't clear a specific data type, you can only wipe the whole pasteboard.
When you start from a blank slate, it is important that you don't add data that removes existing data.
You should generally move from pain to rich to hyper text and add private data at the end.
See the method SystemEventDelegate.
Notice this is called in a worker.
This is to avoid blokcing the application during the On System Event.