O'Reilly logo

REALBasic: TDG, 2nd Edition by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Receiving Apple Events

To receive an Apple event originating from another application (or your own), your project must have an Application subclass. The Apple event’s arrival will trigger a HandleAppleEvent event, whose handler receives three parameters: the event itself, along with its two identifiers as strings. You then parse and respond to the event. To extract the event’s parameters, you use the same properties used for constructing an Apple event. To reply to the Apple event, you set whichever of its Reply properties is appropriate for the datatype of the reply. You must then return true if you handled the Apple event, or false (or nothing) if you reject it; if you return true, the reply will automatically be returned to the originating application.

Three of the four “required” Apple events, "aevt/oapp", "aevt/odoc", and "aevt/quit", are intercepted by REALbasic and do not generate a HandleAppleEvent event. The first two generate a NewDocument event and an OpenDocument event, respectively—see Section 7.2 and Section 24.3. The third simply generates the Quit command, as if you had given it in code. (In REALbasic 3.5, it is routed to your FileQuit menu handler, as if the user had chosen the Quit menu item.)

Warning

You cannot distinguish between a live user quitting your application and an Apple event telling it to quit remotely. A response to quitting that requires a live user (such as a modal dialog) may make quitting your application remotely impossible.

Apple Event Scriptability ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required