user1312991
user1312991

Reputation:

How can a C program on Mac OS/X learn that the user has double-clicked to open an associated file?

Normally in Obj C, NSApplicationDelegate handles this. But how would I do it in C? I guess what I am asking it, how did Mac programs do this before OS/X came along? Thanks.

Upvotes: 2

Views: 131

Answers (1)

user149341
user149341

Reputation:

In Mac OS 9, applications opened documents at launch (or later on) by registering for and receiving an 'odoc' Apple Event at startup. This is nontrivial to do in C, and I'd strongly recommend you not attempt it. In particular, note that this is unlikely to work properly unless your application has a Carbon event loop.

Before even that, there was also a mechanism whereby files for an application to open at launch were specified in a block of memory at the top of the stack. This mechanism no longer exists on OS X, so it's irrelevant today.

Upvotes: 5

Related Questions