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:
Besides the changeset, I have also fixed a few minor inconsistencies with several VM-specific implementations in the OpenSmalltalk-VM repository (see
#508,
#514, and #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 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?
Please test and review! And many thanks to Marcel for his helpful tips!
Best,
Christoph
Carpe Squeak!
|
Hi Christoph! This is great news! I will take a look at it and test it for the Windows platform. Best, Marcel
|
Done and merged into Trunk. Best, Marcel
|
Hi Marcel, thanks for the feedback & merge! :-)
I have already spent some thoughts on this before submitting the changeset, and I did not want to make this event exclusive for the world only but accessible for every morph. However, was this a good idea, or would this be a rather different approach from how
"system events" work (or should work)?
A good precedent may be WindowEvent which is indeed dispatched to the world morph only - at least at the moment. I'm trying to construct an example where another morph could be interested in these events, too. For example, a tool might have opened a session
to some critical external system, maybe an SSH shell, and this tool would like to output an extra warning to the user when a #windowClose event is received. However, should it get access to WindowEvents for this purpose, or should they be hidden behind the
PasteUpMorph facade and we would prefer to design some high-level hook on the world instead which the SSH tool then could register itself against as a "critical operation"? (NB: The shutDown list would not be the right solution in this fictive example - when
#shutDown: is called, the shutdown operation is already in progress which would be "too late" for our tool to reject the shutdown.)
I'm pretty sure we can conduct more or less the same debate for the new proposed SystemLaunchEvent because a SystemLaunchEvent
is basically very similar to a WindowEvent, just without a position but with one or multiple file paths (internally: file streams).
Should you be able to watch an event like this using HandMorph >> #showEvents:?
I think so.
Should you be able to receive
an event like this using an event listener? Probably?
Should you be able to intercept an event like this using an
event filter? I don't know, but could it harm?
Should every morph be able to subscribe to events like this by overriding #handlesSystemLaunch:? I have no idea ...
So I'm looking forward to your opinions on this issue ... Do we need a new event class for this, or does it suffice to tell the PasteUpMorph a "private message" only? My versions browser for #generateDropFilesEvent: contains this old version, too, which would be pretty much our alternative:
Your two cents please! :-)
Best,
Christoph
Von: Taeumel, Marcel
Gesendet: Montag, 2. November 2020 16:40 Uhr An: Thiede, Christoph; [hidden email] Betreff: Re: Changeset: Enhanced integration of drag'n'drop from host
Done and merged into Trunk.
Best,
Marcel
Carpe Squeak!
|
I haven't thought this through, but what I first thought of was something like SystemChangeNotifier. A central instance where objects can register for such global events. It sounds odd to me to deliver the event to every single morph in the system. Most of them are probably not interested. So the interested ones should ask for notifications. If the world morph were to dispatch the event, what about non-Morphic applications? Am Mo., 2. Nov. 2020 um 19:28 Uhr schrieb Thiede, Christoph <[hidden email]>:
|
Hi Jakob, thanks for your reply! :-)
So you are proposing to build a separate dispatching mechanism for system launch events, if necessary, which sounds very reasonable with regard to possible performance issues. In this case, there would be no need for an extra event class and I could couple #generateDropFilesEvent: just a little bit stronger to the world.
> If the world morph were to dispatch the event, what about non-Morphic applications? Now you're touching a sore spot on event generation in general. No skiving, event generation is very closely coupled to Morphic, just because all the event buffer decoding happens in the HandMorph class! If Morphic
is unloaded, the new DnD features cannot be used, just like they were never implemented in MVC, and just like window events which neither ever worked in MVC, too. If we wanted to decouple these aspects, we probably would need to extract most of the event generation
methods into another class (maybe EventSensor? maybe an intermediary abstraction level?) and provide some callbacks for things like launchDrops. But I believe this is enough stuff for a follow-up project - which I personally would not give a high priority
just because I'm not aware of any concrete use case for a non-Morphic event generation framework at the moment. :-)
Any other opinions on this question? Otherwise, I will proceed with eliminating the SystemLaunchEvent soon.
Best,
Christoph
Von: Jakob Reschke <[hidden email]>
Gesendet: Dienstag, 3. November 2020 11:23:24 An: The general-purpose Squeak developers list; Thiede, Christoph Cc: Taeumel, Marcel Betreff: Re: [squeak-dev] WindowEvents and new SystemLaunchEvent/#launchDrop from singleton VM (was: Changeset: Enhanced integration of drag'n'drop from host) I haven't thought this through, but what I first thought of was something like SystemChangeNotifier. A central instance where objects can register for such global events.
It sounds odd to me to deliver the event to every single morph in the system. Most of them are probably not interested. So the interested ones should ask for notifications.
If the world morph were to dispatch the event, what about non-Morphic applications?
Am Mo., 2. Nov. 2020 um 19:28 Uhr schrieb Thiede, Christoph <[hidden email]>:
Carpe Squeak!
|
Free forum by Nabble | Edit this page |