Pass an argument to a bundle application under MacOSX
Matt Connolly
matt at soundevolution.com.au
Wed Jun 27 02:24:29 PDT 2007
Ah. After reading my message, I didn't fully explain the idea. Sorry.
The application could tell at launch time of there was a document =
open requested. For traditional Carbon applications, the application =
receives an event at launch time from the system, "OAPP" for open the =
application, and "ODOC" for open a document. These are handled by =
these virtual functions in the mac implementation:
(in wxApp)
virtual void MacOpenFile(const wxString &fileName) ;
virtual void MacNewFile() ;
The default implementation for "MacNewFile" does nothing.
The default implementation for "MacOpenFile" goes to the wxDocManager =
class to open the document.
I guess the major draw back to this approach is that you need to then =
initialise your application and then wait for the appropriate event =
from the operating system ( OAPP or ODOC ) to determine which mode =
your application should run in.
As far as the argument goes, you'd have to store that in the document =
and read it yourself. I'm not aware of any other ways to pass command =
line arguments to Mac OS X applications.
Hope that helps. Sorry if it's not the perfect solution.
Cheers,
Matt
On 27/06/2007, at 7:06 PM, Don wrote:
>
> Matt,
>
> Thank you for your solutions.
> The first one (script.command) works fine, but less seamless.
>
> I want to try the second one (your "Mac friendly" solution).
> However, I don't see how to pass the argument to the program.
>
> Regards,
> Don
>
>
> "Matt Connolly" <matt at soundevolution.com.au> a =E9crit dans le =
> message de
> news: 3EE1C607-0DE2-46D8-B183-7F713BDE5184 at soundevolution.com.au...
>> Don,
>>
>> If you needed to run it as a script, you could create a script =
>> command to
>> launch the application. Save a text file as "launch.command", with
>> something like this:
>>
>> ---
>> #!/bin/sh
>>
>> /path/to/MyApplication.app/Contents/MacOS/MyApplication --command-
>> line-argument
>>
>>
>> ---
>>
>> The "launch.command" file needs to executable (as in linux). The draw
>> back is that it launches the Terminal application and runs from a =
>> window
>> there. Even if you append a "&" at the end of the command line, =
>> closing
>> the Terminal window will terminate the application. Of course, if =
>> it's a
>> console application, this isn't a problem. :)
>>
>> Otherwise, my best "mac friendly" solution would be to create a =
>> document
>> type in the application's launch bundle, and have the user launch =
>> the
>> application via a "document" for an alternate running mode.
>>
>> Best,
>> Matt
>>
>>
>>
>>
>>
>> On 25/06/2007, at 10:41 PM, Don wrote:
>>
>>>
>>> Hi,
>>>
>>> I did a wx program which takes 1 argument in order to be =
>>> launched in 2
>>> mode.
>>> This mechanism works well under MS Windows (by shortcuts) and =
>>> Linux (by
>>> script)
>>>
>>> A problem is encountered under MacosX, due to its bundle system.
>>> Is there a way to bundle my wx program by passing 1 argument in =
>>> order
>>> that
>>> user can launch it via Finder?
>>>
>>> Thank you in advance.
>>>
>>> Don
>>>
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------------- =
>>> -
>>> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>>> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
>> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2174 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070627/fa=
a5cbb1/smime.bin
More information about the wx-users
mailing list