Drag and drop file on GeUserArea

On 28/04/2015 at 12:58, xxxxxxxx wrote:

I'm trying to add the ability for a user to drag and drop a file on my plugin.
Is there some way I can get the file path of a file dropped on a GeUserArea?



On 29/04/2015 at 07:10, xxxxxxxx wrote:

Hi Chris,

To get the drag information call self.GetDragObject(msg) from the GeUserArea.Message(). See this post for an example of implementing Message() and filtering BFM_DRAGRECEIVE message.
The  'object' key in the returned dictionary holds the drag object data: in the case of a file it's its name.

On 29/04/2015 at 20:24, xxxxxxxx wrote:


Excellent! Works fine, but I'm a little puzzled by a couple of things.

  1. If I don't do:
return  self.SetDragDestination(c4d.MOUSE_MOVE)

from inside:

if msg.GetId()==c4d.BFM_DRAGRECEIVE:

C4D intercepts my image file and displays it in the 'Picture Viewer'.
How does that return prevent that?

I tried just 'return True', but it seemed like that didn't always stop C4D from loading the image file.
Should 'return True' always stop it, or is there some magic in 'return self.SetDragDest...'



never sets the mouse cursor no matter what I try.  Should it?

Since the drag starts outside the userarea, it is a file, is there some way I can detect the dragging over the userarea and trigger a redraw() so I can display something while they are dragging, before they drop the file?



On 06/05/2015 at 23:38, xxxxxxxx wrote:

Hi Chris,

  1. Returning self.SetDragDestination(c4d.MOUSE_MOVE) ensures that your code intercepts BFM_DRAGRECEIVE message.

  2. Only BFM_DRAGRECEIVE is sent when drag and drop is begun from outside the user area. And while hovering the user area only BFM_DRAW/DrawMsg() is sent so unfortunately there's no way to know if the mouse is dragging or not.

Sorry for the late reply.