6 Replies Latest reply: Aug 23, 2012 5:43 AM by Daves61 RSS

    How to choose .app files in the FileOpenChooser dialog?

    Daves61 Community Member

      Hi,

       

      I am working on a plugin and want to allow the user to browse through the system to choose an .app (Application) file on Mac.

      Currently I'm using OpenDialog() function of SDKFileOpenChooser dialog for this. It's working correctly on Windows but on Mac, when the dialog opens up, .app file appears to be disabled (Not selectable).

      Please tell me what filter should I add so that one can choose files with extension .app.

        • 1. Re: How to choose .app files in the FileOpenChooser dialog?
          AidySun Community Member

          There is a method AddExtension in the interface IOpenFileDialog.

          • 2. Re: How to choose .app files in the FileOpenChooser dialog?
            Daves61 Community Member

            I am using SDKFileOpenChooser dialog. To add filter, we either need TypeInfoID for that file or FileType and extension.

            Using this code, I found out the typeInfoID for .app files. It came out to be 291.

             

            TypeInfoID tpID = FileTypeRegistry::GetFileTypeInfoIDForFile(appIDFile);

             

            Then I tried to add filters in both ways, it's still appear to be disabled (not selectable). Thus, not allwoing to choose .app files.

             

            SDKFileOpenChooser openChooser;

                        FileTypeInfo currentFiletypeInfo = FileTypeRegistry::GetCurrentFileTypeInfo(291);

                        openChooser.AddFilter(currentFiletypeInfo.GetFileType(), currentFiletypeInfo.GetFileExtension(), "App_Filter");

             

                                                                                       or


                        openChooser.AddFilter(291, "App_Filter");

            openChooser.ShowDialog();

             

             

            Can anyone please help me.

            • 3. Re: How to choose .app files in the FileOpenChooser dialog?
              lomorgan Adobe Employee

              On OS X a .app file is just a special type of directory (you can verify this by right clicking on one in finder and selecting "Show Package Contents"). Could that be why it isn't showing up in the file chooser? I had a similar issue with Air's file chooser on a recent project.

              • 4. Re: How to choose .app files in the FileOpenChooser dialog?
                Daves61 Community Member

                Yes, that's correct. It is a package file.

                Is there any way to select it? I need to get the path of this file.

                • 5. Re: How to choose .app files in the FileOpenChooser dialog?
                  lomorgan Adobe Employee

                  You could try SDKFolderChooser and see if that works. If it does you could try looking at the source for SDKFolderChooser (in <SDK>/common/SDKFileHelper.cpp), see how it gets the IOpenFileDialog, and see if you can add a filter to that directly to only let the user select .app files. Not sure if that will work, but it might be worth trying at least.

                  • 6. Re: How to choose .app files in the FileOpenChooser dialog?
                    Daves61 Community Member

                    SDKFolderChooser also didn't work.

                    It seems InDeisgn API doesn't recognize .app extension. This is because when I used this code to add filter in File Chooser dialog, I found that extension being retrieved using GetFileExtension() is "Text" which is incorrect.

                     

                    FileTypeInfo currentFiletypeInfo = FileTypeRegistry::GetCurrentFileTypeInfo(291);

                    openChooser.AddFilter(currentFiletypeInfo.GetFileType(), currentFiletypeInfo.GetFileExtension(), "App_Filter");