views:

202

answers:

2

I'm writing a C program for mac, and I need to allow the user to choose an application to send an apple event to. I can create a navigation window, using NavCreateChooseFileDialog, but I can't get it to enable any .app files. If I restrict the types using NavDialogSetFilterTypeIdentifiers, it will only allow me to select applications like MS Office, that don't have .app in the folder name. Everything else is greyed out.

Any ideas?

Thanks

A: 

Remember that .app bundles are directories, so you may need to enable some sort of allow-directories (or, more likely, enable-bundles) option.

I'm sorry that I can't offer more specific help. I started with Carbon, but never did touch Navigation Services.

Peter Hosey
Yes, I've tried various NavDialogSetFilterTypeIdentifiers settins and nav...chooseObject, and it didn't help.
Brian Postow
A: 

Make sure to set the flag kNavSupportPackages in inOptions.optionFlags for NavCreateChooseFileDialog, and put 'APPL' in the types list (might as well still use that param instead of NavDialogSetFilterTypeIdentifiers(), that way you'll run on 10.3-) and you should be good to go, I just tried.

Alternatively, if you don't mind using Cocoa, you can use -[NSOpenPanel runModalForTypes:[NSArray arrayWithObjects:@"app", nil]] (which also lists non-.app applications), and then you're only one FSPathMakeRef((UInt8*)[path fileSystemRepresentation], &fsRef, NULL); away from an FSRef.

Do remember that, in either case, the file you get may be an alias so you will have to try and resolve aliases.

Pierre Lebeaupin