[squeak-dev] Changeset: Enhanced integration of drag'n'drop from host

Marcel Taeumel marcel.taeumel at hpi.de
Mon Nov 2 15:40:23 UTC 2020

Done and merged into Trunk.

Am 26.10.2020 07:47:02 schrieb Marcel Taeumel <marcel.taeumel at hpi.de>:
Hi Christoph!

This is great news! I will take a look at it and test it for the Windows platform.

Am 23.10.2020 14:11:28 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
Hi all! :-) I'm glad to officially submit my dropFiles changeset today, finally. It enhances the integration of drag'n'drop (DnD) events delivered by the VM from the host operating system to the image, following one of Marcel's ideas: Instead of generating separate DropFilesEvent instances, every DnD event from the VM is translated into a TransferMorph that can be dragged into every morph or tool like every other Morph of TransferMorph, too.

What is the goal of this changeset?
This design change entails two key advantages: First, every dragged host element is represented by a first-class object (which is a TransferMorph) instance. Second, as a consequence, applications do no longer need to implement a separate protocol for handling host DnDs (which was #dropFiles:/#wantsDropFiles:) but only need to provide one single proper implementation of #acceptDroppingMorph:event:/#wantsDroppedTransferMorph:. In particular, this also enables developers who use the ToolBuilder(Spec) framework to handle contents dropped from the host system since the old dropFiles protocol was never forwarded to the ToolBuilder framework.

How does it work?
There have already been complete implementations of the DropPlugin on the VM side for all important platforms (Windows, Linux, and macOS) for a long time (almost 20 years ...) which record four different types of drag events, namely: #dragEnter, #dragMove, #dragLeave, and #dragDrop. However, until now, only the last of them, #dragDrop, has been handled on the image side (see HandMorph >> #generateDropFilesEvent:). The main work of this changeset can be found in just this method where I added support for the other drag types in order to create, move, and release a TransferMorph accordingly. Other changes include:
* Deprecated, but kept working the old DropFilesEvent protocol (these events are still processed, but a DeprecationWarning is signaled if any morph actually handles them).
Migrated the only implementation of the old dropFiles protocol, which is PasteUpMorph, to the unified TransferMorph protocol.
Introduced a new event class + protocol for SystemLaunchEvent (aka #launchDrop) which is generated by a singleton VM when it has been invoked with a new image file (see class comment). That #launchDrop is a curious hack on the VM side to reuse the DnD protocol but has completely different semantics that now are separated on the image side.
* Implemented the SystemLaunchEvent protocol on PasteUpMorph.
Besides the changeset, I have also fixed a few minor inconsistencies with several VM-specific implementations in the OpenSmalltalk-VM repository (see #508 [https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/508], #514 [https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/514], and #518 [https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/518]) that have already been merged (thanks to all reviewers!).

What's the current state of the changeset?
I have successfully tested the changeset on Windows (Win 2004) and Ubuntu/X11. Also, I made sure it works with Squeak.js and TruffleSqueak. However, I do not have any possibility to test it on the OSVM implementations for macOS and iOS, so your help and feedback especially for these platforms will be greatly appreciated!
Please see the attached demo video on how to test the changeset: Simply drag some files into an inspector field or a workspace and you should receive a list of FileStreams and/or FileDirectories. Also, aborting a drag operation should not fail, i.e. drag a file over the image but then drop the file in another window.

What's next?
There is much more potential for a comfortable host DnD integration! Concretely, I am having two downstream goals in mind: First, dropping other content types besides files and/or directories in your image, such as texts or images (currently, the DropPlugin implementations that I could try out are restricted to the former two types). Second, dragging objects out of the VM to save them as a file, or even better, to drop them in a second image! Vanessa has told me [https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/508#issuecomment-655021654] that this was even possible in the past for certain platforms, but unfortunately, the relevant code appears to be dead nowadays. Nevertheless, I have stumbled upon a lot of stubs for both features in the DropPlugin and HandMorph code, and I'm looking forward to reviving them in some interesting follow-up projects!

Which related contributions/discussions are there else?
* System-ct.1156 (Inbox, fixes double prompt for handling a dropped file when the first dialog was canceled; not included in the changeset)

* [squeak-dev] Re: Please try out | Inspector Refactoring =) [http://forum.world.st/Please-try-out-Inspector-Refactoring-tp5114974p5116422.html] (the thread contains some interesting brainstorming about MIME type support for dragging inside the image)

Please test and review! And many thanks to Marcel for his helpful tips!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201102/831fab6d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 133740 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201102/831fab6d/attachment-0001.png>

More information about the Squeak-dev mailing list