Dropping a file on an App Icon

Hello,

I have a quick question for you. I can drag and drop files onto an app window – and that works without any issue. Yet, when I try to drag and drop the same files onto the compiled program’s icon, nothing happens. (I am working with MacOS.)

Here’s what I’ve done so far…

  1. Added the File Types Group (to state the type of files that can be opened.)
  2. Added drag and drop to a canvas. (That works.)
  3. Added a documentOpen() event at the App level.

I can drag and drop files on the canvas without issue, but drag and drop onto the app icon is still not allowed. Ideas? Suggestions?

Byron

You have to set the file type group elements correctly. First you have to setup the correct identifier and conforms to items. Once you have done that you need to configure the Type on the right hand side to File and Role to View or Edit. The Rank can be default if it is your type or alternate if you can open it but it really belongs to someone else.

3 Likes

Hi Ian,

Ah, that makes sense… Thank you very much! Yay, this works. :slight_smile:

Byron

1 Like

Wouldn’t it be cool if the Xojo documentation explained it this clearly?

2 Likes

https://documentation.xojo.com/getting_started/using_the_ide/file_type_group_editor.html

It sort of talks about Role and Rank, but the dialog image is out of date.

1 Like

I just can’t get this working for some common file types with 2021r2.1 under Mac Ventura.

  • Any filetype roles are set to “None” the moment I run a debug build, regardless of what I set them or Rank to prior to running.
  • The roles remain at “Edit” when I compile, but files dropped on the built app’s dock icon still won’t open.

EDIT: I do not have Role set to Execute, I’ve tried View and Edit. They get set to None when I run, regardless.

Is this maybe a bug with 2021r2.1 or am I doing something wrong? Can it be fixed via Info.plist? My Info.plist file after compilation has no keys for UTExportedTypeDeclarations or CFBundleDocumentTypes, but it does have UTImportedTypeDeclarations:

Got it working for Excel files. I copied Excel’s Info.plist, removed everything but UTExportedTypeDeclarations, CFBundleDocumentTypes, and UTImportedTypeDeclarations, saved as XML (Excel’s is binary), and dragged it into the IDE.

@Julia_Truchsess These are my XLSX and CSV definitions, which work for my App:


2 Likes

@Julia_Truchsess if you have this trouble again, on a Mac, you can drag and drop files into the FileTypeGroup and it will go look up the correct properties for the item. I would bet that it would work properly that way.

1 Like

That’s a great tip, thanks, @Greg_O! It doesn’t however, solve what seems to be my root issue, which is that as soon as I run the program, Role reverts to None for all my FileTypes. :woman_shrugging:t3:

Ok, so that bug has to do with changing the role not marking the file type group as needing to be saved. Make your changes, change the name of something and then change it back. (Manually, don’t use undo). Then save.

No joy.

Screen Recording 2024-02-25 at 1.18.54 PM (1)