Forum

Drag and drop stuff on a Renderer

hey all,

since vl allows to patch with windows forms stuff, I gave a try to DragDrop events. things are going well so far!

drop

the idea here is to retrieve the main Control associated with the Renderer and allow DragDrop events on it. then, you just need to subscribe to the DragEnter event and you get an observable carrying the path of the file(s) that’s been dropped.

a few things I could not sort out for now but that would be pretty interesting :

  • allow users to create controls from Rectangles, so that you could create different “drop zones”. I tried by splitting a rectangle and using a Create (Control) out of it that I added to the ControlCollection of the form, but the Drag events never seemed to fire from those.
  • as you can see on the gif, the patch reacts to the DragEnter event. for some reason, DragDrop event would never fire in my tests…
  • also, you can see that Renderer still displays “forbidden” icon when something’s dragged on it, is it somehow forced?

this patch is available here !

8 Likes

You have to enable on the control AllowDrop. see this node: https://github.com/microdee/mp.essentials/blob/master/string/ControlDragAndDropNode.cs#L104 (btw this has been in mp.essentials for a while)

That should also make the cursor appropriate too

1 Like

thanks d, will give it a try :)