DragnDrop in 6?

Hi Folks

Is there a sample of using DnD in 6 to drag in files from the desktop. In particular I need to drag an image file from the desktop and grab its name so I can add the name to a table and the file to our storage area??

Since I’m dragging from outside Servoy I cant fire the onDrag event so cant grab the file name.

Guidance appreciated?

Hi Ian,

I think you just need the DnDFile Bean. That’s what I use in 5.X. Does 6 comes with a DnD bean?

But since you are dragging from outside Servoy, you should check the File plugin or SmartDoc’s. The SmartDoc will extract not just the name of the file but the meta data: Overview - SmartDoc Plugin - ServoyForge

Just FYI: You probably know that you can use the HTML area to display your images (by creating a variable/datasource that points out to the location of you image file). But, you might want to use the Browser Suite to display the images. It gives you more options that Servoy HTML area. (https://www.servoyforge.net/projects/browsersuite)

JC

In Servoy 6 you don’t need any beans to do that. Just attach an onDragOver method to your form, set a breakpoint, drag a file from the Desktop to your solution and see what happens.

patrick:
In Servoy 6 you don’t need any beans to do that. Just attach an onDragOver method to your form, set a breakpoint, drag a file from the Desktop to your solution and see what happens.

This is excellent! Is there a sample solution to demo this?

Not necessary. Just attach a method and see what happens.

I think what you will get is a java.util.List<java.io.File> as event data. In short, you get a List of files (because it could be several files that are dropped).

patrick:
Not necessary. Just attach a method and see what happens.

I think what you will get is a java.util.List<java.io.File> as event data. In short, you get a List of files (because it could be several files that are dropped).

Brilliant thanks Patrick - I’ll try that out later today.

Thanks JC too.

Ian

EDIT Correct Patrick - the event.data does have the file name and path shown - excellent.