Checking for .textclipping

I’m trying to create a FileTypeGroup to only accept .textclipping files.
But, as until now, when I assign the FileTypeGroup to the accepted files that are dragged into a Window, the windows accepts ALL files.
I have set the FileTypeGroup like this:

Name: clipping
Display Name: application/octet-stream
Extensions: .textclipping
Identifier: public.textclipping
Conforms to public.textclipping
MacOS Types: TEXTCLIPPING

I know something is wrong, but I don’t know what.

In your window.Open event (or whichever control you want to be able to accept the file drop) use the line

Me.AcceptFileDrop("application/octet-stream")

The string in the AcceptFileDrop statement has to exactly match the Display Name.

Thank you for replying.
I tried it and it still accepts all types of files that I drop into it, not just the .textclipping files.

In that case I would suspect that somewhere in the app there is another AcceptFileDrop statement that is in conflict with this one. Test it by commenting out this statement and see if file drops are still accepted.

I commented it out and the windows stopped accepting any kind of file drop.
After activating the statement, I can drag all types of files… PDFs, JPGs, TXTs, RTFs, etc…

Then the only other thing I can think of to look at is other entries in the FileTypeGroup(s). Is there another one with the Display Name “application/octet-stream”?

Or you could try changing that one display name to something else in the FileTypeGroup entry and in the AcceptFileDrop statement.

This is my FileTypeGroup. I really don’t know how to make it to only accept .textClipping files :frowning:

I’ve never added a dot in the extension.

Even removing the dot, the window still accepts all types of files, not just the textClipping files.

I think you need to fill in the MacOS options to make it work correctly, per the UG: File Type Group Editor, i.e. Identifier and Conforms To. These were listed in the original post but aren’t in the screenshot.
Also, why is the display name the Mime Type?

The dot is necessary if you are on Windows. On Mac, apparently it is not necessary.

This works perfectly for me on Windows with Xojo 2021r2.

According to the UG, the Mac options are necessary on the Mac for this to work.

The OP didn’t indicate if he was on Mac or Windows, but in the first post, the Mac-specific information was provided, but didn’t actually appear in the later screenshot (which looks like a Mac…). I’d start there.

I can’t get the file drop to work for clipping either.

I made 2 file types:

Apple has a list of UTIs somewhere but I only found some old docs that lead to /dev0.

In the Open-ish event of the window I added some code:

'me.AcceptFileDrop(FileTypes.clipping)
me.AcceptFileDrop(FileTypes.mbox)

I had the mbox working. Then I did some testing and now it’s back to not working (all files are accepted). For the clipping all files were accepted.

Where in the FileType class are the Mac Options? I also see the LR has an entry for FileTypeSet.All but nothing on FileTypeSets…
FWIW I’m see the same accept all behavior. I note that, if you enter the name of the filetype(set?) in the AcceptFileDrop method and use completion, it offers the item(s) in the filetype, as well as All and AllFileTypes, which isn’t defined anywhere that I can find (and generates an error on compile… definite bug here).
A possible workaround is that text clipping actually has the text in the dropobject text field and returns true for TextAvailable (despite being a file), so you could do this in the DropObject handler and just silently ignore everything else:

if obj.TextAvailable then
  msgbox "Dropped: "+obj.Text
end if

That said, I don’t know if any other file type would also present text this way… text files do not.

That will work perfectly for me.
Although, it would be nice to know why is it that all file types are being accepted.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.