Drag'n'Drop : Dragging a file into an app

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Drag'n'Drop : Dragging a file into an app

Rob Lally
Hi all,

I'm looking for some help. I was wondering if anyone could point me to an example of how enable dragging files into an
app. I can get dragging of objects from one shell to another running - but not from a non Dolphin source.

Pointers to docs or examples would be most appreciated.

Thanks,

Rob.


Reply | Threaded
Open this post in threaded view
|

Re: Drag'n'Drop : Dragging a file into an app

Chris Uppal-3
Rob,

> I'm looking for some help. I was wondering if anyone could point me to an
> example of how enable dragging files into an app. I can get dragging of
> objects from one shell to another running - but not from a non Dolphin
> source.

That functionality isn't exposed in vanilla Dolphin, so you'll need an
extension.  I use Louis and Steve's 'DH Shell Data Transfer' package which is
part of their 'Shell' project at:
    http://www.dolphinharbor.org/dh/projects/shell/index.html

To use it, do something like:

          ShellDragDropSession registerDropTarget: each view.

for each of the presenters you want to be 'active'.  I do that in my main
Shell's #onViewOpened.  Similarly you need to call:

              ShellDragDropSession revokeDropTarget: each view.

in your #onViewClosed.

Unfortunately, I don't know of any way to make the whole window, including
sub-panes, be 'active' except my looping over them.  A Windows thing...

With that in place, the "normal" Dolphin drag-and-drop stuff is hooked into the
Windows stuff (as a drop target, I don't know whether it's also possible to
make it a drag source as easily).  You'll also (as normal) have to make the
relevant Views be
     #isDropTarget: true
either in the view composer or from code.  And you'll have to register interest
in the #dragOver: and #drop: events triggered off the relevant Presenters (not
their Views), which is also as per normal.

Files dropped into the app show up as objects with format #Filenames (note the
plural -- the object is a collection of filenames) in the DragDropSession.

I've found one problem with it, which may be because I'm not using it quite
right (so beware ;-)  When the image is saved and restarted, the connection to
Windows is implicitly revoked (obviously) so ShellDragDropSession attempts to
reconnect automatically, but that doesn't (for me anyway) seem to work
properly.  I haven't found a workaround for it (simply hooking image startup
from my Shell to reconnect then doesn't work since that interferes with
ShellDragDropSession's own attempt).  But since it is irrelevant to deployed
applications, and I don't often close down my image anyway, I haven't worried
too much about it.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Drag'n'Drop : Dragging a file into an app

user
Thanks Chris,

I'll dig into it.

R.


Chris Uppal wrote:

> Rob,
>
>
>>I'm looking for some help. I was wondering if anyone could point me to an
>>example of how enable dragging files into an app. I can get dragging of
>>objects from one shell to another running - but not from a non Dolphin
>>source.
>
>
> That functionality isn't exposed in vanilla Dolphin, so you'll need an
> extension.  I use Louis and Steve's 'DH Shell Data Transfer' package which is
> part of their 'Shell' project at:
>     http://www.dolphinharbor.org/dh/projects/shell/index.html
>
> To use it, do something like:
>
>           ShellDragDropSession registerDropTarget: each view.
>
> for each of the presenters you want to be 'active'.  I do that in my main
> Shell's #onViewOpened.  Similarly you need to call:
>
>               ShellDragDropSession revokeDropTarget: each view.
>
> in your #onViewClosed.
>
> Unfortunately, I don't know of any way to make the whole window, including
> sub-panes, be 'active' except my looping over them.  A Windows thing...
>
> With that in place, the "normal" Dolphin drag-and-drop stuff is hooked into the
> Windows stuff (as a drop target, I don't know whether it's also possible to
> make it a drag source as easily).  You'll also (as normal) have to make the
> relevant Views be
>      #isDropTarget: true
> either in the view composer or from code.  And you'll have to register interest
> in the #dragOver: and #drop: events triggered off the relevant Presenters (not
> their Views), which is also as per normal.
>
> Files dropped into the app show up as objects with format #Filenames (note the
> plural -- the object is a collection of filenames) in the DragDropSession.
>
> I've found one problem with it, which may be because I'm not using it quite
> right (so beware ;-)  When the image is saved and restarted, the connection to
> Windows is implicitly revoked (obviously) so ShellDragDropSession attempts to
> reconnect automatically, but that doesn't (for me anyway) seem to work
> properly.  I haven't found a workaround for it (simply hooking image startup
> from my Shell to reconnect then doesn't work since that interferes with
> ShellDragDropSession's own attempt).  But since it is irrelevant to deployed
> applications, and I don't often close down my image anyway, I haven't worried
> too much about it.
>
>     -- chris