Documents Drag n Drop on App

I haven’t worked with my own files for a while (latest Xojo version). I can drag and drop a file onto my open App’s main window ok but I can’t drop a file onto the unopened App icon.

What would be stopping that? or what have I forgotten?

Hi Martin,

When you drop a file onto your App icon, that should start your App (if it isn’t open already) and then also trigger the App.OpenDocument Event.

It is in the OpenDocument event that you would handle how to open or process the file, as required by you app.

Note: the single file As FolderItem parameter of OpenDocument means the event is called for each file dropped on the icon. Which means if you drop multiple files on the icon, the OpenDocument event is called multiple times in quick succession.

Also note: the above is also true when you use Finder to select one or more files and “Open With…” to launch your app.

At least that is what is working for me, but I only play on macOS these days.

Hope that helps.

Have you set up a FileType group to define the type? You may need that for launching from the Finder, per the user guide.

Note there was a recent thread on some possible bugs in how this works on Mac.

1 Like

I have that bit set up as per some other Apps I have done. When I drop a file on the Window when the App is open it works fine.
The current problem is the App icon doesn’t highlight at all when I try and drag a file onto it so the App doesn’t launch?

Which bit? The OpenDocument Event or the FileType group mentioned by Matthew?

(Thank you @Matthew_Dinmore1, I neglected to mention that)

From my experience, macOS may need the FileType macOS Options filled in to help Finder recognize your app for one that can handle certain file types. See my example screen-shot:

Also, I found the Xojo “Project” > “Run Paused” menu item to be very helpful when debugging the OpenDocument event.

“Run Paused” builds the debug version of the app, but doesn’t launch it until you either double-click the app file itself, drop a file on it or use Finder on a selected file and use the “Open With…” context menu (and choose the debug app).

Note: If the list of apps in the “Open With…” context menu doesn’t show your debug app, then typically I think this means something is not set right with the FileType groups in Xojo.

Didn’t know that, thanks

1 Like

This is what I have set up which works for drag n drop on App when already running.
There must be something else I’m not seeing. The finder displays the correct names for KIND

I deleted the FileType as the original project was from 2007 and started again… no different??

Well, that’s a good sign I think.

I have not fooled around with custom file extensions too much (where “File type is unique to this app” is checked).

But what happens after you build your app, copy it to your /Applications folder, and you double-click one of your custom files (with either the .clg or .clz extension) in Finder? Does it launch your app?

A dialog appears asking to identify the App to be associated or search the App store.

Goood !

That also means that you forgot to set a property somewhere (probably). I fire Xojo and search in App.

Did you generate the application ?

Did you reboot the computer after generating the application ?

Did you drop a custom file onto your application icon ?

In order…

Sorry, I do not found in current Xojo (or docs) what you missed. And Xojo 2015r1 do not runs on M1.

Then, I associated the document to the application (Get Info in the Finder).

When I fired the document icon, I get:

And then a second dialog with macOS icon saying the same or so:

Note the Help button in the windows.

The application is running in the IDE.

And the application seems to need to be sealed, signed, and delivered (err, no, this is another matter);: notarized !

Your Xojo settings look correct to me, so I’d like to see the Info.plist file that Xojo creates when you build or run the application.

I put me.AcceptFileDrop(filetypes.All) in the Open event of the main window and in App>OpenDocument I am ready to pass the folder item to a method to handle the file?
I created a new project and started from scratch but same thing, the compiled App won’t accept a drop file. Pretty sure it is something I am doing wrong and the Saved files are showing the correct File Type in Finder.

Not sure if anyone is able to run this project as I was testing PictureToJPEGStringMBS(Clipart,100), for the graphic save (just rem out)

I may forgot to say something.

In my test, I loaded a current project created with Xojo 2015r1, build on Intel that do that.

Once “imported” in Xojo 2021r2.1 / M1, run in the IDE, double-click in a csv file opens… Numbers… and then I already wrote what happened next.

So, I too do not know what to do next (what you miss).

Hi Martin,

I took a look at your example. From what I can tell (via the MBS Quicklook plugin) you built the example in 2021r2.1.

I’m assuming of course that in the FileType editor (of your example project) you originally set the Role and Rank drop-down options to something like your screen-shot?

Because what I’m wondering is, if you reopen your example now, and look at the FileType entries you put in - are the Role and Rank options reset back to “None” & “Default”?

If the above is true, then what you have is <> which was still present when r2.1 was released. And I believe this issue will prevent your files from being associated with your app.

My apologies for not realizing or recognizing this behaviour earlier (my memory is not what it used to be).

But, don’t despair, as mentioned in this morning’s Xojo newsletter, Release 3 is on its way. :wink:

I hope that helps.


Bingo! Without these the macOS won’t associate the files with the application.

I can add a file type editor to App Wrapper, but it will take time. Please let me know the amount of interest in this feature.

1 Like

Yes that seems to be the problem it keeps resetting to none :slight_smile:


It already was since…