Drag and drop a file onto an app icon?

Coming from a different approach than you guys, I’ve always allowed any file type to be dropped and then in the OpenDocument event I attempt to figure out what the file type is.

Mainly because we do a lot of image editing and there are so many RAW formats in the wild (some with the same extension), I found it easier to simply try and open the image file, if I don’t get an image in return, I know it’s not supported.

I have a stupid question as I’ve done that:

when in time did you add the File Types (FT) in the File Types Set ?

Explanation: I added two FT month ago and added a third last week or so. It was that one who is ignored.

On the other hand, I just created a sample demo for the bug and it does not have the bug at all. Read my entry on the subject.
(all three FT have been added at the same time, from the same icon : the default text/plain with appropriate changes).

I only have to redo that in my 30MB and watch how goes the changes…

[quote=122175:@Robert Birge]These things work for me on OSX. They do not work for me on Windows. Has anyone gotten drag and drop to work with a Windows app? If so, I would be grateful for some insights into how to do this.
[/quote]

For OSX you specify a Filetype under “BUILD SETTINGS” for this to work… and it does…
but how (or can) you do this for Windows…

Drag a file to the desktop/dock application icon, and have it open the app, and fire OPENDOCUMENT event

I believe on windows you only need to handle the opendocument event. Any kind of file can be dropped on the app icon.

Thanks, I was hoping that was all it required… I assume you can guess where this is going :slight_smile:

I’m new to Xojo.

In 2020 Relese 1, Filetype under “BUILD SETTINGS” doesn’t exist.
How you do this on 2020 r1…?

What OS Entry did you choose ?

Click in macOS (or if you are on macOS, click in This Computer).

Thanks for your quick reaction!

I’m on macOS 10.15(Catalina) and choose macOS, but FileType choice doesn’t be shown…
It’s same when choosing “This Computer”.

Under “Menu” I can see FileTypeGroup1. Is’nt that the one you are looking for?

Moreover, top-right of the picture: may be you should think about your app name; unless your app’s name is really “app-64bit”, you may choose a different name. And the “bundle Identifier”, should contain your app-name.
For instance, if the app-name is “Wonderful Pictures”, the bundle identifier could look like “com.mycompany.wonderfulpictures”.

They’re not under build settings any more. We consolidated the functionality into File Type Groups.

@shiori: Oups… Sorry.

http://documentation.xojo.com/getting_started/using_the_ide/file_type_group_editor.html#macOS-Only_File_Type_Properties

@Greg: thanks.

@Carlo_Rubini @Greg_O_Lone
Thanks.
I fixed my app-name and bundle indentifier.

I want to make my app to accept any type of files, but the app’s icon will not accept any file.
Maybe I have something wrong with FileTypeGroup settings….
Any advice would be appreciated.


http://documentation.xojo.com/getting_started/using_the_ide/file_type_group_editor.html#Mac_Information

Hi,
from the picture, it seems the fileTypeGroup is all right.
The next step is the code you put into the “OpenDocument” event handler of App.
You’ll notice that such event has got a “item as folderitem” parameter; in fact such “item” is the file you drop onto the app’s icon.
Now, I suppose your app has got a specific menu to open files; so try copy-pasting that code into the “openDocument” event, making sure you use the word “item” in the code you paste.
After that, if the file you drop onto the app’s icon has got the extension you typed into the FileTypeGroup, then the dropping should be succesfull.
(I would make a test using --in FileTypeGroup-- a single extension, maybe preceded by a “.”; and later add other extensions as required).

The LR States:

  • Extensions . Required. The file extensions for the file type (the “.” prefix is optional). When you have multiple extensions, list them all separated by semi-colons.

You used colon in your screen shot.

psd = PhotoShop
ai = Adobe Illustrator
indd = InDesign ???

Are your Conform To field correct for the above ?

@Carlo_Rubini
Thanks, finally I did it!
Your answer was very helpful.

@Emile_Schwarz
Thanks, I overlooked it…

When you have multiple extensions, list them all separated by semi-colons.

I fixed my “Extensions” and now my app recognizes multiple extensions.

2 Likes

Please let me add one more question.

When I drop a file whose type is “special/any”,
my app’s Dock icon allows to drop, but Finder’s icon does not.

If I drop a file whose type is common,
Dock’s and Finder’s both allow to drop it.

What is the difference between the two…?