Drag n Drop

I have drag n drop working on the Mac side but don’t seem to be able to get it on windows.
Is it different?
Should the same code work cross platform?

Yes, but not in the way you think: if you drop an item from the Explorer into a Dialog, you do not get the macOS same behavior… (the file change its location)

Last time I checked, yes.

Maybe you can elaborate a bit with what you are doing (and how) “drag and drop” ?

In the open event of the Window I have the various filetypes
me.AcceptTextDrop
me.AcceptPictureDrop
me.acceptFileDrop(“Text/Plain”)
me.AcceptFileDrop(“Crosswords”)
me.AcceptFileDrop(“CrosswordPlayerFile”)
me.AcceptFileDrop(“Shape”)

In the DropObject event in the Window I check for various objects
I also do the same in a Canvas on the window where I accept a some graphic variations
me.acceptPictureDrop
me.acceptFileDrop(“image/jpeg”)
me.acceptFileDrop(“image/png”)
me.acceptFileDrop(“image/x-bmp”)
me.AcceptTextDrop
me.acceptFileDrop(“Text/Plain”)
me.AcceptFileDrop (“Crosswords”)
me.AcceptFileDrop (“CrosswordPlayerFile”)

When I drag an object on macOS I get a + symbol as I go over the App Window but on Windows I get the Red slash

This and some others:

Where do you get this syntax ?

AcceptFileDrop require a File Type Set, not a String.

Read:
http://documentation.xojo.com/UserGuide:File_Type_Sets
http://documentation.xojo.com/topics/user_interface/desktop/supporting_drag_and_drop.html

It reject the drop.

Make sure to use a filetype. It seems to work better on Windows.

http://documentation.xojo.com/api/deprecated/rectcontrol.html#rectcontrol-acceptfiledrop

[quote=474898:@Martin Fitzgibbons]me.AcceptFileDrop (“Crosswords”)
me.AcceptFileDrop (“CrosswordPlayerFile”)[/quote]
These are unknow types.

And yes, FileType1.All returns a string.

I see so the same as Filters for dialog boxes. Stragley it seems to work fine on the Mac side

So would I reduce it to the following if I want to only allow Png, Jpg, .txt and the 3 filetypes that are in my filetype set that are native to my app?

me.acceptPictureDrop
me.acceptFileDrop(“image/jpeg”)
me.acceptFileDrop(“image/png”)
me.AcceptTextDrop
me.acceptFileDrop(“Text/Plain”)
me.AcceptFileDrop (filetypes.All)

Furthermore would I need to have this in the Window Open and Canvas Open event or just the Window Open Event?

Who will deal with the data:

the Window ?
the Canvas ?

place the code in the appropriate Open Event…

Nota:
http://documentation.xojo.com/api/deprecated/window.html#window-acceptfiledrop
http://documentation.xojo.com/api/deprecated/rectcontrol.html#rectcontrol-acceptfiledrop

Do I have to define Jpg, Png etc in my app filetypes set on Windows?
I haven’t on the Mac side and it works but not on Windows.
The file types native to my app now work on mac and win

Turns out that for Windows the public files need to be part of the Filetype set eg jpg, png to be recognised for drag n drop but it isn’t necessary on the Mac side