Drag & Drop not working on macOS Sonoma?

I have a large app (“Lightwright”) that accepts dragging and dropping picture files on a canvas control. It’s been working great for 10+ years and has not been rewritten for API 2.0. Recently, I received bug reports from users saying that drag & drop isn’t working, and when I tried it on my laptop running macOS 14.4.1, it did not work.

I have a window with a canvas control on it, in the canvas’s .Open event, there is this bit of code to initialize it for drag & drop:

Me.AcceptPicture Drop

When a picture (.png, .jpg, etc.) is dropped on it, the control used to raise a .DropObject event, but it doesn’t raise anything at all.

Thoughts on how to get this working again? I’ve heard rumors that Apple has deprecated drag and drop, but that’s hard to imagine.

Thank you!

Are you using Xojo 2024r1.1?
Can you create a sample project that reproduce the problem?

Yes, and I just made a one-window API 2.0 test app and it fails, too.

I’d check a couple of things…

  1. Make sure you still have file types for .png, .jpg, etc. within your FileTypeGroup within your project
  2. Make sure your open event includes each file type from #1
    Me.AcceptFileDrop("image/png")
  3. You’ll want to repeat steps 1-2 for each file type you want to accept (e.g. jpg)
1 Like

Ok, you may share it here for someone to take a look and create an Issue with it for Xojo to take a look.

Also I can’t say if drag and drop is deprecated or not by Apple, but I’m using Xojo’s drag and drop just fine under Sonoma and earlier, as well as Windows 10/11.

Right now the only issue I’m having is the following:

#75936 Drag Text Failure Under Windows (Formatted Text)

…which won’t apply to you as you’re using images.

Make sure your app isn’t quarantined.

2 Likes

It’s running inside Xojo, so I can’t imagine how it could be quarantined…?

I’m just using Me.AcceptPictureDrop. I use the AcceptFileDrop(“image/png”) in Lightwright, but AcceptPictureDrop has always worked fine for simple standard file types.

How do I post a copy of the test project (6kb zipped) to this conversation?

1 Like

Using Dropbox, Google drive, or other share service and post the link.

Here’s a Dropbox link to my test drag & drop project:

I think I had this “issue” years ago. And It was because I wasn’t accepting “files”, but “pictures”.

1 Like

@John_McKernon Just checked another one of my projects after looking at your sample and here’s the fix…

After the line…

Me.AcceptPictureDrop

…add the following:

Me.AcceptFileDrop("image/png")
Me.AcceptFileDrop("image/jpg")

Things should work from there.

1 Like

All I needed was

me.AcceptFileDrop("image/png")

And the file types defined as

Then I could receive the obj.FolderItem at the DropObject event.

2 Likes

OK, that does work, though it’s very specific and the Xojo .PictureAvailable made it easy.

If I want to accept various kinds of files, how do I know what the actual filetype actually is when the file doesn’t have an extension? Most of the user’s picture files my users don’t end in .png or .jpg or .jpeg or .tiff unless they’re on Windows. Should I just try to open the file as various formats until I get one that opens it successfully?

obj.FolderItem.Type should match a FileType defined, as “image/png” for example, in the DropObject event.

2 Likes

I learn something new every day, thank you all for your generous help!

1 Like

If you’re unsure of a filetype, select your Filetypes in the IDE, and drag the file onto it, like below.
The first image is the file being dragged, the second shows new filetype created when it was dropped, with all the information you need.


1 Like

(post deleted by author)

1 Like

@Emile_Schwarz I’m not getting GraphicFileTypes.All to compile. Are you by chance API1?