how the drag and drop to upload files on pc’s work

321 views

how the drag and drop to upload files on pc’s work

In: 5

5 Answers

Anonymous 0 Comments

It is slightly different between different systems (Windows, OSX, X11, Wayland, JavaScript, etc.). But the basic principle of it is that when you start to drag something an event is issued to the application controling that area of the screen that a drag have started. It is then possible for this application to return an object idendifying what you dragged with a unique referance as well as things like its icon and name. When you drop the object a simliar event is sent to the receiving application as well as the sending application. These will then negotiate between themselves what to do. Some applications might only expect a text element in which case the path to the file is used, some expect an image which can be done by having the sending application open the file as an image and then transfer this image to the receiving application. But if they negotiate to send the file then the applications will end up sending the files from one to the other.

As you might expect not all applications are able to properly negotiate with each other. Things are even more complex when one of the applications is a JavaScript application running on a web page inside the browser which requires the interfaces to be translated through the browers and such. But when it works it is quite cool.

You are viewing 1 out of 5 answers, click here to view all answers.