GithubHelp home page GithubHelp logo

miyako / 4d-tips-write-pro-paste-reference Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 17 KB

How to calibrate the pasteboard so that references are pasted with style and value

License: MIT License

4D 100.00%

4d-tips-write-pro-paste-reference's Introduction

version

4d-tips-write-pro-paste-reference

How to calibrate the pasteboard so that references are pasted with style and value

The probem

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.

The Solution

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.

4d-tips-write-pro-paste-reference's People

Contributors

miyako avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.