 |
 |
"Open With" On mac OS
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2009
Status:
Offline
|
|
i have created a Mac OS application using XCode to Compile and Qt Frameword to develop
i am facing a major problem regarding the "open with" command on Mac OS
first of all , my application is supposed to support type files such as "djf" files
if i open my program and work on it for a while , the user has the option to save his work file as djf files
now if the user clicks back on the djf file , my application is supposed to open and load the djf file clicked by the user
the first problem that i am facing is that , the "open with" command on MAC OS is graying out my application so the user has to change the options on the top from "Recommended applications" to "all applications" so that the user will be able to click on my application and select it
the second problem that i have is that even though the user selects my application, my application opens a new instance of it self rather than loading the file being passed as an argument using the command line
i did few tests on my application and i found that my application never receives the file name as an argument in the main.cpp and that was the reason of why it doesnt load the file
i did few more tests using the command line of mac OS where a user can simply say:
open -a [application path/application.app] [argument "file name"]
i noticed that my application never receives [argument "file name"]
then i noticed that if you remove "open -a" from the command line and just keep [application path/application.app] [argument "file name"] while diving in to the application.app/Contents/MacOS/applicationName
this will certainly pass all the parameters needed and my application will load the saved work document to be edited once again
so i am pretty confused , why "open -a" is not passing the right arguments
please note: that open -a only passes two arguments to my application
1- the application path
2- a wierd argument which says "psn_0_xxxxxx"
but as soon as you type in the command line
application.app/Contents/MacOS/applicationName [filename]
this will pass the right arguments to my application
so my question is
since "open -a" is the argument being passed to the console when you double click a file to open with a specific application
how can i make these file types open with my application ? because its not working for me
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
I have not investigated the underpinnings much, as I always use the "Document Based Application" template when I (rarely) create anything that needs to open files like this, but I think that the standard method of telling an application to open a file is to pass it a AppleEvent. This is so you can pass an already running process the open event, whereas argc/argv only gets done at startup (for the rest you should be in your run loop).
And are you properly registering your application for the extensions in your Info.plist? And then if your application is not in /Applications (say it is in the build folder of your project), then I would not expect the indexer that finds that information to have indexed it before you run the application.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Does your app claim the types in its Info.plist?
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2009
Status:
Offline
|
|
ok i build my app in a different folder NOT the application folder of mac os
once the application is built and the info.plist is created for my app , i open that file and i add my own types
here is how i do it
i have got the Root of course
- CFBundleDocumentTypes (Array)
-- 0 (Dictionary)
--- CFBundleTypeExtentions (Array)
---- 0 (String) djf
--- CFBundleTypeIconFile (String) djf.icns
--- CFBundleTypeName (String)
--- CFBundleTypeRole (String)
--- LSIsAppleDefaultForType (Boolean) yes
the rest of the info.plist is done by default correctly, i just add the above
so yes my application does claim the types in the info.plist as i mentioned above
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2009
Status:
Offline
|
|
this might look better , so you can see how it is being indented
-- CFBundleDocumentTypes (Array)
---- 0 (Dictionary)
------ CFBundleTypeExtentions (Array)
-------- 0 (String) djf
------ CFBundleTypeIconFile (String) djf.icns
------ CFBundleTypeName (String)
------ CFBundleTypeRole (String)
------ LSIsAppleDefaultForType (Boolean) yes
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |