lotus



previous page: 8.1) What are AppleEvents? (IAC - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 8.3) Are there any limits or tradeoffs with AppleEvents? (IAC - Mac Programming)

8.2) What are the four required AppleEvents? (IAC - Mac Programming)




Description

This article is from the Mac Programming FAQ, by Jon Watte h+@austin.metrowerks.com with numerous contributions by others.

8.2) What are the four required AppleEvents? (IAC - Mac Programming)

There are four events your application really must implement if you
want to sell it: the kCoreEventClass class, kAEOpenApplication,
kAEQuitApplication, kAEOpenDocuments and kAEPrintDocuments events IDs.
When you support these events (or any AppleEvents) you will not get
startup info through GetAppParams() anymore, unless you run under System
6 of course. The kAEOpenApplication event will be sent to you when the
user double-clicks your app and it's not started yet. When receiving it,
you can put up a new untitled window.

kAEOpenDocuments is sent when the user double-clicks your apps documents.
Note that if the first AppleEvent you receive is a kAEOpenDocuments
event, the user started your app by double-clicking its documents.

kAEPrintDocuments is sent when the user selects your documents and
chooses "Print" in the Finder menu. If this is the first AppleEvent you
receive, you should print the documents and then quit the application
again; if you received a kAEOpenApplication or kAEOpenDocuments event
before this, you should just print the documents and close them when
you're done.

kAEQuitApplication is sent to you when the user chooses "Shutdown" or
"Restart" from the Apple Menu. You should ask the user whether he wants
to save any unsaved changed documents, and then quit unless the user
presses Cancel.

Interestingly enough, you can use these four AppleEvents to send even to
non-AE-aware applications, and the system will translate these events
into fake menu selections for you.

A good way of shutting down the Finder is to send it a Quit AppleEvent.
You should send a Quit AppleEvent to File Sharing Extension before you
shut down the Finder, though; the FSE is found by looking for a process
with the creator 'hhgg'.

 

Continue to:















TOP
previous page: 8.1) What are AppleEvents? (IAC - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 8.3) Are there any limits or tradeoffs with AppleEvents? (IAC - Mac Programming)