-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Copying and pasting (Larry Tesler) are so common, a bit like walking or talking, that you don't really know how it works.
This component gives you the means to explore the 2 containers associated with these actions in 4D.
When you copy something like text, image, file, mail, ... the developer of the application where you perform this action (it can be the system if you are on the desktop) puts in the clipboard the information corresponding to what is copied. But he doesn't know where you're going to paste what you've just memorized. If you make the paste in the same application, it can afford to put only information that it knows how to manage since it is the same developer who will manage the "paste". But he doesn't know… So he has to plan what you can do with it and fill the clipboard with different formats of what is being copied.
If, for example, you copy a text in a word processor he will be able to put in the clipboard: Plain text, utf8 text, utf16 text, styled text in RTF format, styled text in HTML format...
For an image, copied on the desktop, you may want to paste the contents of the image, in PNG or TIFF or JPEG format, or its path in system format or POSIX…
He must have thought of everything because it is especially at the time of pasting that the work is done. At the moment you paste, the application developer where this action takes place (it is not necessarily the same one) first looks at where the action takes place then according to this place he will shop around in the clipboard to find what is most appropriate.
It has to choose the image format if the target accepts an image, the text format if the target accepts text, or a private format if it is more appropriate and the copy and paste is done in the same application. Or not at all if no value can be pasted into the target. In this case, he has taken the precaution of disabling the "Paste" item so as not to mislead you.
I tend to say that:
-
Managing copying is like filling a shopping cart with everything that will be useful to us and to other applications if you want to give the possibility to copy data in your application that can be pasted elsewhere.
-
Manage the pasting, it is like shopping in the available shopping cart to find and take what interests us most.
And it's exactly the same for drag and drop, except it's not the same basket.
In 4D, we call these shopping carts a "container", without differentiating between copy-paste and drag and drop, although they are different. The drag-and-drop container has a limited lifespan between the moment you start dragging and the moment you drop ... or you release the mouse button. The contents of the clipboard, on the other hand, persist as long as the user does not copy anything else. It is not erased when you paste its contents. It is even retained when you exit the application.