Restrict DropObject/FileType to only folders


I’m trying to setup a FileType for a DropObject so it will only accept a folder and not a file. I’ve had this working in the past, but the settings I used then don’t seem to be working now. The canvas I’m using to test is accepting any file drop. Does anyone know what the latest way to do this is on a Mac?

I’m on Xojo 2013 R3, Mac OS X 10.8.4, compiling for Cocoa (maybe that’s the problem, I think these settings have worked in Carbon in the past)

Here’s what I have in my FileType:
Display Name: special/folder
Object Name: Folder
MacType: fold
MacCreator: MACS
UTIs: public.folder

I’ve also tried without the UTI and with just the UTI and had the same results.

In the Open event for the canvas, I have, “me.AcceptFileDrop(FileTypes1.Folder)”
And in the DropbObject event, I check for FolderItemAvailable and then display the path of the folderitem in a text area. No matter what I drop there, the path is displayed in the text area.

Thanks in advance,

Add the following code to the DragEnter event for the canvas

if obj.FolderItem.Directory = False then Return True
Then nothing can be dropped on the canvas except folders.

Thanks, Dale, that’s a good idea. Is there simply no way any more to make a FileType filter for folders?


  1. You are compiling to Cocoa
  2. Things are different on Cocoa
  3. Dale gives you an answer I do not saw on the docs.

Now, you have to know that you can continue to use your old skill if you compile to Windows and Linux (but I do not test Linux).


I wanted to tell you to put Dale’s code in a #TargetCocoa (check the real spelling and how to use it in the docs) block, so it will not do a duplicate work o Windows / Linux and I forgot8


Thanks, Emile. That’s good advice, although this happens to be a Mac-only app. It would, indeed, be nice if the docs mentioned the workaround for the folders. I’ll file a feedback report.

Dales answer should word regardless of platform

Yes Dave, Dale’s code will work regardless of platform, but it is not needed in Windows (just like it is not needed for Carbon and probably Linux).