TweetFollow Us on Twitter

MACINTOSH C
MACINTOSH C: A Hobbyist's Guide To Programming the Mac OS in C
Version 2.3

© 2000 K. J. Bricknell

Go to Contents

(Chapter 1)

APPLE EVENTS

A link to the associated demonstration program listing is at the bottom of this page



Introduction

As stated at Chapter 2 - Low Level and Operating System Events, events are broadly categorised as low-level events, Operating System events, and high-level events.

Using high-level events, an application can instruct another application to perform a specific action, such as adding a row to a spreadsheet or changing the font size of a paragraph. An application can also request information from another application; for example, it might request a dictionary application to return the definition of a particular word.

Fig 1 shows the general event-handling mechanism. In Fig 1, three different applications are communicating with each other by sending and receiving high-level events. Note that high-level events are placed in a separate queue maintained by the operating system and that a high-level event queue is maintained for each application that has announced itself as capable of receiving high-level events.

(General event handling mechanism)

For effective communication between applications, an application must define the set of high-level events it responds to and let other applications know the events it accepts. For a high-level event sent by one application to be understood by another application, the sender and receiver must agree on a protocol, that is, on the way the event is to be interpreted.

Apple Events

Apple events are high-level events whose structure and interpretation are determined by the Apple Event InterProcess Messaging Protocol (AEIMP). Applications typically use Apple events to request services and information from other applications and to provide services and information in response to such requests.

Communication between two applications which support Apple events is initiated by a client application, which sends an Apple event to request a service or information. The application providing the service or information is called a server application. Fig 2 shows a common Apple event, called the Open Documents event. The Finder (which is, itself, an application) is the client; it requests that the application My Application open the documents named Document A and Document B. My Application responds by opening windows for the specified documents.

(Client and server)

An application can also send Apple events to itself, thus acting as both client and server.

To identify Apple events and respond appropriately, every application can rely on a vocabulary of standard Apple events which developers and Apple have established for all applications to use. These events are defined in the Apple Event Registry: Standard Suites. The standard suites (groups of Apple events that are usually implemented together) include:

  • The required suite, which consists of five Apple events that the Finder sends to applications. The required Apple events are:

    • Open Application.

    • Re-open Application.

    • Open Documents.

    • Print Documents.

    • Quit Application.

  • The core suite, which consists of the basic Apple events, including Get Data, Set Data, Move, Delete and Save, that nearly all applications use to communicate.

  • The functional-area suite, which consists of a group of Apple events which support a related functional area, and which include the Text suite and the Database suite.

  • The appearance suite, which consists of four Apple events used to advise all foreground applications when one of the following changes has been made in the Fonts tab of the Appearance control panel:

    • Appearance.

    • Large system font.

    • Small system font.

    • Views font.

Historical Notes

The Re-open Application Apple event was introduced with Mac OS 8.

The Apple event relating to an appearance change was introduced with Mac OS 8. The Apple events relating to large system font, small system font, and vews font changes were introduced with Mac OS 8.5.

The Finder uses the required Apple events as part of the mechanism for launching and terminating applications. Your application must support the required Apple events.

This chapter is primarily concerned with the required Apple events and the Appearance Manager Apple events, exploring the subject of Apple events only to the extent necessary to gain an understanding of the measures involved in supporting the required and appearance suites.

Apple Event Attributes and Parameters

When an application creates and sends an Apple event, the Apple Event Manager uses arguments passed to Apple Event Manager functions to construct the data structures that make up the Apple event. An Apple event comprises attributes (which identify the Apple event and denote its task) and, often, parameters (which contain information to be used by the target application).

Apple Event Attributes

An Apple event attribute is a structure which identifies the event class, event ID, target application, and other characteristics of an Apple event. Taken together, the attributes denote the task to be performed on any data specified in the event's parameters. After receiving an Apple event, a server application can use Apple Event Manager functions to extract and examine its attributes. Apple events are identified by their event class and event ID attributes.

Event Class

The event class is the attribute that identifies a group of related Apple events. It appears in the message field of the event structure for an Apple event (see Fig 3). For example:

  • The required Apple events have the value 'aevt' in the message field of their event structures. 'aevt' is represented by the constant kCoreEventClass.

  • The Appearance Manager Apple events have the value 'appr' in the message field of their event structures. 'appr' is represented by the constant kAppearanceEventClass.

(Content of event structure - high level event)

Event ID

The event ID is the attribute which identifies the particular event within the event class. In conjunction with the event class, the event ID uniquely identifies the Apple event and communicates what action the Apple event should perform. It appears in the where field of the event structure for an Apple event (see Fig 3). For example, the event ID of an Open Documents event has the value 'odoc', which is represented by the constant kAEOpenDocuments. The kCoreEventClass constant in combination with the kAEOpenDocuments constant identifies the Open Documents event to the Apple Event Manager.

The following are the event IDs for the five required Apple events and the four Appearance Manager Apple events. (Those introduced with Mac OS 8.5 appear in dark blue.)

Event ID Value Description
kAEOpenApplication 'oapp' Perform tasks required when a user opens your application.
kAEReopenApplication 'rapp' Perform tasks required when a user "re-opens" your application.
kAEOpenDocuments 'odoc' Open documents.
kAEPrintDocuemnts 'pdoc' Print Documents.
kAEQuitApplication 'quit' Quit your application.
kAEAppearanceChanged 'thme' Current appearance has changed. Action as required.
kAESystemFontChanged 'sysf' Current system font has changed. Action as required.
kAESmallSystemFontChanged 'ssfn' Current small system font has changed. Action as required.
kAEViewsFontChanged 'vfnt' Current views font has changed. Action as required.

Target Application

In addition to the event class and event ID, every Apple event must include an attribute which specifies the target application's address.

Apple Event Parameters

An Apple event parameter is a structure containing data that the target application uses. Apple events can use standard data types, such as strings of text, long integers, boolean values, and alias structures, for the data in their parameters. As with attributes, a client application can use Apple Event Manager functions to extract and examine the parameters of an Apple event it has received.

There are various kinds of Apple event parameters, including direct parameters and additional parameters.

Direct Parameters

A direct parameter usually specifies the data to be acted upon by the target application. For example, a list of documents is contained in the direct parameter of the Print Documents event.

Additional Parameters

Some Apple events also take additional parameters, which the target application uses in addition to the data specified in the direct parameter. For example, an Apple event for arithmetic operations may include additional parameters which specify operands in an equation.

Required and Optional Parameters

All parameters are either required parameters or optional parameters. A required parameter is one which must be present for the target application to carry out the task denoted by the Apple event. An optional parameter is a supplemental Apple event parameter that can also be used to specify data to a target application. Direct parameters are usually defined as required parameters in the Apple Event Registry - Standard Suites.

Interpreting Apple Event Attributes and Parameters

Fig 4 shows the major Apple event attributes and direct parameter for the Open Documents event.

(Major attributes and direct parameters in Open Documents event)

To process this event, your application would use the AEProcessAppleEvent function, which uses the event class and event ID attributes to dispatch the event to My Application's Open Documents handler. In response, the Open Documents handler opens the documents specified in the direct parameter.

Data Structures Within Apple Events

The Apple Event Manager constructs its own internal data structures to contain the information in an Apple event.

Descriptor Structures

Descriptor structures are the building blocks used by the Apple Event Manager to construct Apple event attributes and parameters. A descriptor structure is a data structure of type AEDesc. It consists of a handle to data and a descriptor type which identifies the type of data to which the handle refers:

     struct AEDesc
     {
       DescType descriptorType;  // Type of data.
       Handle   dataHandle;      // Handle to data.
     };
     typedef struct AEDesc AEDesc;

The descriptor type is a structure of type DescType which, in turn, is of data type ResType, that is, a four-character code. Constants are used in place of these codes when referring to descriptor types. The following are some of the major descriptor type constants, their values, and the kind of data they identify:

Descriptor Type Value Description of Data
typeChar 'TEXT' Unterminated string.
typeType 'type' Four-character code.
typeBoolean 'bool' One-byte Boolean value.
typeLongInteger 'long' 32-bit integer.
typeAEList 'list' List of descriptor structures.
typeAERecord 'reco' List of keyword-specified descriptor structures.
typeAppleEvent 'aevt' Apple event structure.
typeFSS 'fss ' File system specification.
typeKeyword 'keyw' Apple event keyword.
typeNull 'null' Nonexistent data (handle whose value is NULL).

The following illustrates the logical arrangement of a descriptor structure with a descriptor of type typeChar, which specifies that the data handle refers to an unterminated string:

Data Type AEDesc
Descriptor type: typeChar
Data: "Summary of Sales"

The following illustrates the logical arrangement of a descriptor structure with a descriptor type of typeType, which specifies that the data handle refers to a four-character code (in this case the constant kCoreEventClass, whose value is 'aevt'):

Data Type AEDesc
Descriptor type: typeType
Data: (kCoreEventClass)

Address Descriptor Structure

Every Apple event includes an attribute specifying the address of the target application. A descriptor structure which contains an application's address is called an address descriptor structure:

     typedef AEDesc AEAddressDesc;  // An AEDesc which contains addressing data.

The address in an address descriptor structure can be specified as one of the four basic types (or as any other descriptor types you define that can be coerced to one of these types):

Descriptor Type Value Description
typeApplSignature 'sign' Application signature.
typeSessionID 'ssid' Session reference number.
typeTargetID 'targ' Target ID structure.
typeProcessSerialNumber 'psn ' Process serial number.

Like several other data structures defined by the Apple Event Manager for use in Apple event attributes and Apple event parameters, an address descriptor structure is identical to a descriptor structure of data type AEDesc; the only difference is that the data for an address descriptor structure must always consist of an application's address.

Keyword-Specified Descriptor Structures

After the Apple Event Manager has assembled the necessary descriptor structures as the attributes and parameters of an Apple event, your application must use Event Manager functions to request each attribute and parameter by keyword. Keywords are arbitrary names used by the Apple Event Manager to keep track of various descriptor structures. The AEKeyword data type is defined as a four-character code:

typedef FourCharCode AEKeyword; Constants are typically used to represent keywords. Keywords for Attributes. The following is a partial list of keyword constants for Apple event attributes:

Attribute Keyword Value Description
keyEventClassAttr 'evcl' Event class of Apple event.
keyMissedKeywordAttr 'miss' Keyword for first required parameter remaining in an Apple event.
keyAddressAttr 'addr' Address of target or client application.
keyEventIDAttr 'evid' Event ID of Apple event.
keyEventSourceAttr 'esrc' Nature of the source application.
keyReturnIDAttr 'rtid' Return ID for reply Apple event.

Keywords for Parameters. The following is a list of keyword constants for commonly used Apple event parameters:

Parameter Keyword Value Description
keyDirectObject '----' Direct parameter.
keyErrorNumber 'errn' Error number parameter.
keyErrorString 'errs' Error string parameter.

The Apple Event Manager associates keywords with specific descriptor structures by means of a keyword-specified descriptor structure, a data structure of type AEKeyDesc that consists of a keyword and a descriptor structure:

     struct AEKeyDesc 
     {
       AEKeyword descKey;  // Keyword.
       AEDesc    descContent;  // Descriptor structure.
     };
     typedef struct AEKeyDesc AEKeyDesc;

The following illustrates a keyword-specified descriptor structure with the keyword keyEventClassAttr, the keyword that identifies an event class attribute. It shows the logical arrangement of the event class attribute for the Open Documents event shown at Fig 4.

Data Type AEKeyDesc
Keyword: keyEventClassAttr
Descriptor Structure: Descriptor Type: typeType
Data: Event Class
(coreEventClass)

Descriptor Lists, AE Structures, and AppleEvent Structures

Descriptor Lists

When extracting data from an Apple event, you use Apple Event Manager functions to copy data to a buffer specified by a pointer, or to return a descriptor structure whose data handle refers to a copy of the data, or to return lists of descriptor structures (called descriptor lists).

A descriptor list is a data structure of type AEDescList defined by the data type AEDesc. That is, a descriptor list is a descriptor structure whose handle refers to a list of other descriptor structures (unless it is an empty list):

     typedef AEDesc AEDescList;  // List of descriptor structures.

The following illustrates the logical arrangement of the descriptor list that specifies the direct parameter of the Open Documents event shown at Fig 4. This descriptor list consists of a list of descriptor structures which contain alias structures to filenames.

Data Type AEDescList
Descriptor type: typeAEList
Data: List of descriptor structures:
Descriptor type: typeAlias
Data: Alias structure for filename (Document A)
Descriptor type: typeAlias
Data: Alias structure for filename (Document B)

This descriptor list provides the data for a keyword-specified descriptor structure.

AE Structure

Keyword-specified descriptor structures for Apple event parameters can in turn be combined into an AE structure, which is a descriptor list of type AERecord:

     typedef AEDescList AERecord;  // List of keyword-specified descriptor structures.

The handle for a descriptor list of data type AERecord refers to a list of keyword-specified descriptor structures that can be used to construct Apple event parameters. An AE structure has the descriptor type typeAERecord and can be coerced to several other descriptor types.

Apple Event Structure

An Apple event structure, which is different from an AE structure, is another special descriptor list of data type AppleEvent and descriptor type typeAppleEvent:

     typedef AERecord AppleEvent;  // List of attributes and parameters for Apple event.

An Apple event structure describes a full-fledged Apple event. Like the data for an AE structure, the data for an Apple event structure consists of a list of keyword-specified descriptor structures. Unlike an AE structure, the data for an Apple event structure is divided into two parts, one for attributes and one for parameters. This division allows the Apple event to distinguish between an Apple event's attributes and its parameters.

Passing Descriptor Lists, AE Structures and Apple Event Structures to Apple Event Manager Functions

Descriptor lists, AE structures and Apple event structures are all descriptor structures whose handles refer to a nested list of other descriptor structures. The data associated with each data type may be organised differently and used by the Apple Event Manager for different purposes. In each case, however, the data are identified by a handle in a descriptor structure. This means that you can pass an Apple event structure to any Apple Event Manager function that expects an AE structure. Similarly, you can pass Apple event structures and AE structures, as well as descriptor lists and descriptor structures, to any Apple Event Manager functions that expect structures of data type AEDesc.

Example Complete Apple Event

Fig 5 shows an example of a complete Apple event - a data structure of type AppleEvent containing a list of keyword-specified descriptor structures that name the attributes and parameters of an Open Documents event.

(Data structures within Open Documents event)

Handling Apple Events

A client application uses the Apple Event Manager to create and send an Apple event requesting a service or information. A server application responds by using the Apple Event Manager to process the Apple event, extract data from the attributes and parameters of the Apple event and, if necessary, add requested data to the reply event returned by the Apple Event Manager to the client application.

As a first step in supporting Apple events, and as previously stated, your application should support the required Apple events sent by the Finder. To support the required Apple events, you must:

  • Set the isHighLevelEventAware flag in the 'SIZE' resource of your application.

  • Test for high-level events in your application's event loop. An Apple event (like all high-level events) is identified by a message class of kHighLevelEvent in the what field of the event structure. Your application should therefore test the what field of the event structure to determine whether it contains the value represented by kHighLevelEvent.

  • Use AEProcessAppleEvent to process the Apple events. AEProcessAppleEvent first identifies the Apple event by examining the data in the event class and event ID attributes. It then uses that data to call the appropriate Apple event handler provided by your application.

  • Provide handlers for the required Apple events in your application. Your Apple event handlers must extract the pertinent data from the Apple event, perform the requested action, and return a result.

  • Use AEInstallEventHandler to install your Apple event handlers. This function installs handlers in an Apple event dispatch table for your application. The Apple Event Manager uses this table to map Apple events to handlers in your application When your application calls AEProcessAppleEvent, the Apple Event Manager checks the dispatch table and, if your application has installed a handler for the event, calls the handler. Each entry in the Apple event dispatch table should specify:

    • The event class.

    • The event ID.

    • A universal procedure pointer to the Apple event handler.

    • A reference constant.

      The reference constant is passed to your handler by the Apple Event Manager each time your handler is called. Your application can use this reference constant for any purpose. If your application does not use the reference constant, specify 0.

    Accordingly, the parameters for the call to AEInstallEventHandler are the event class, the event ID, a pointer to the event handler, a reference constant, and false.

    false causes the handler to be installed in the application's Apple event dispatch table. true causes the handler to be installed in the system's Apple event dispatch table. The system Apple event dispatch table is a table in the system heap containing handlers that are available to all applications and processes running on the same computer. The handlers in your application's Apple events dispatch table are available only to your application. If AEProcessAppleEvent cannot find a handler for the Apple event in your application's Apple event dispatch table, it looks in the system Apple event dispatch table for a handler. If it does not find a handler in the system table, it returns the errAEEventNotHandled result code.

Apple Event Handlers

Each Apple event handler must be a function which uses this syntax:

     OSErr  theEventHandler(AppleEvent *appleEvent,
                                 AppleEvent *reply,
                                 long handlerRefcon);
appleEvent The Apple event to handle. Your handler uses Apple Event Manager functions to extract any parameters and attributes from the Apple event and then perform the necessary processing.
reply The default reply provided by the Apple Event Manager.
handlerRefcon Reference constant stored in the Apple event dispatch table entry for the Apple event. Your handler can ignore this parameter if your application does not use the reference constant.

Apple event handlers must generally perform the following tasks:

  • Extract the parameters and attributes from the Apple event.

  • Check that all required parameters have been extracted.

  • Perform the action requested by the Apple event.

  • Dispose of any copies of the descriptor structures that have been created.

  • Add information to the reply Apple event if requested.

Extracting and Checking Data

You must use Apple Event Manager functions to extract the data from Apple events. The following are the main functions involved:

Function Description
AEGetAttributePtr Uses a buffer to return a copy of the data contained in an Apple event attribute. Used to extract data of fixed length or known maximum length.
AEGetParamDesc Returns a copy of the descriptor structure or descriptor list for an Apple event parameter. Usually used to extract data of variable length, for example, to extract the descriptor list for a list of alias structures specified in the direct parameter of an Open Documents event.
AECountItems Returns the number of descriptor structures in a descriptor list. Used, for example, to determine the number of alias structures for documents specified in the direct parameter of an Open Documents event.
AEGetNthPtr Uses a buffer to return a copy of the data for a descriptor structure contained in a descriptor list. Used to extract data of fixed length or known maximum length, for example, to extract the name and location of a document from the descriptor list specified in the direct parameter of the Open Documents event.

Data Type Coercion. You can specify the descriptor type in the resulting data from these functions. If this type is different from the descriptor type of the attribute or parameter, the Apple Event Manager attempts to coerce it to the specified type. In the direct parameter of the Open Documents event, for example, each descriptor structure in the descriptor list is an alias structure and each alias structure specifies a document to be opened. All your application usually needs to open a document is a file system specification structure (FSSpec) of the document. When you extract the descriptor structure from the descriptor list, you can request that the Apple Event Manager return the data to your application as a file system specification structure instead of an alias structure.

Checking That All Required Parameters Have Been Retrieved. After extracting all known Apple event parameters, your handler should check that it has retrieved all the parameters that the source application considered to be required. To do this, determine whether the keyMissedKeywordAttr attribute exists. If this attribute does exist, your handler has not retrieved all the required parameters, and it should return an error.

Interacting With the User

In some cases, the server application may need to interact with the user when it handles an Apple event. For example, your handler for the Print Documents event may need to display a print options dialog box and get settings from the user before printing . The Apple Event Manager does not allow the server application to interact with the user in response to a client application's Apple event unless at least two conditions are met:

  • First, the client application must set flags in the sendMode parameter of the AESend function to indicate that user interaction is allowed.

  • Second, the server application must either:

    • Set flags to the AESetInterActionAllowed function indicating that user interaction is allowed. (These flags relate to permitting interaction where the client and server are the same application, the client application is on the same computer as the server, or the client is on any computer.)

    • Set no user interaction preferences (that is, make no call to AESetInterActionAllowed ), in which case AEInteractWithUser (the function used to initiate interaction with the user when your application is a server responding to an Apple event) assumes that only interaction with a client on the local computer is allowed.
If these two conditions are met, and if AEInteractWithUser determines that both the client and server applications allow user interaction under the current circumstances, AEInteractWithUser brings your application to the foreground if it is not already in the foreground. Your application can then display its dialog box or alert box or otherwise interact with the user.

Performing the Requested Action and Returning a Result

When your application responds to an Apple event, it should perform the standard action requested by the event.

Your Apple event handler should always set its function result to either noErr, if it successfully handles the Apple event, or to a non-zero result code if an error occurs. If your handler returns a non-zero result code, the Apple Event Manager adds a keyErrorNumber parameter to the reply Apple event. This parameter contains the result code that your handler returns.

Disposing of Copies of Descriptor Structures

When your handler is finished with a copy of a descriptor structure created by AEGetParamDesc and related functions, it should dispose of it by calling AEDisposeDesc.

Required Apple Events - Contents and Required Action

Your application receives the five required Apple events from the Finder in these circumstances:

  • If your application is not open and the user elects to open it from the Finder without opening or printing any documents (either by double clicking the application's icon or by selecting the icon and choosing Open from the Finder's File menu), the Finder launches your application (using the Process Manager) and sends it an Open Application event.

  • If your application is already open and the user attempts to "open" it from the Finder (either by double clicking the application's icon or by selecting the icon and choosing Open from the Finder's File menu), the Finder sends your application a Re-open Application event.

    The Re-open Application event was introduced with MAC OS 8 to cater for a situation which could confuse inexperienced users. The specific situation is where the application is open but has no open windows. Because of the absence of a window, the user does not realise that the application is running, attempts to "open" it from the Finder, and then fails to notice the menu bar change. The intention of the Re-open Application event in such circumstances is to cause the application to open a window, providing more obvious visible evidence to the user that the application is, in fact, open.

  • If your application is not open and the user elects to open one of your application's documents from the Finder, the Finder launches your application (using the Process Manager) and sends it an Open Documents event.

  • If your application is not open and the user elects to print one of your application's documents from the Finder, the Finder launches your application (using the Process Manager) and sends it the Print Documents event. Your application should print the selected documents and remain open until it receives a Quit Application event from the Finder.

  • If your application is open and the user elects to open or print any of your application's documents from the Finder, the Finder sends your application the Open Documents or Print Documents event.

  • If your application is open and the user chooses Restart or Shut Down from the Finder's Special menu, the Finder sends your application the Quit Application event.
The following is a summary of the contents of the required Apple events sent by the Finder and the actions they request applications to perform:

Open Application event
Attributes: Event Class: kCoreEventClass
Event ID: kAEOpenApplication
Parameters: None.
Requested Action: Perform tasks your application normally performs when a user opens your application without opening or printing any documents, such as opening an untitled document window.
Re-open Application event
Attributes: Event Class: kCoreEventClass
Event ID: kAEReopenApplication
Parameters: None.
Requested Action: If no windows are currently open, open a new untitled document window.
Open Documents event
Attributes: Event Class: kCoreEventClass
Event ID: kAEOpenDocuments
Required parameters: Keyword: keyDirectObject
Descriptor type: typeAEList
Data: A list of alias structures for the documents to be opened.
Requested Action: Open the documents specified in the keyDirectObject parameter.
Print Documents event
Attributes: Event Class: kCoreEventClass
Event ID: kAEPrintDocuments
Required parameters: Keyword: keyDirectObject
Descriptor type: typeAEList
Data: A list of alias structures for the documents to be printed.
Requested Action: Print the documents specified in the keyDirectObject parameter, opening windows for the documents only if your application can interact with the user.
Quit Application event
Attributes: Event Class: kCoreEventClass
Event ID: kAEQuitApplication
Parameters: None.
Requested Action: Perform any tasks that your application would normally perform when the user chooses Quit from the application's File menu. (Such tasks typically include releasing memory and requesting the user to save documents which have been changed.)

Your application needs to recognise two descriptor types to handle the required Apple events: descriptor lists and alias structures.

As previously stated, in the event of an Open Documents or Print Documents event, you can retrieve the data which specifies the document as an alias structure, or you can request that the Apple Event Manager coerce the alias structure to a file system specification structure. The file system specification provides a standard method of identifying files.



Main Apple Event Manager and Appearance Manager Constants, Data Types, and Functions Relevant to Required Apple Events and Appearance Manager Apple events

In the following, those constants introduced with Mac OS 8.5 appear in dark blue.

Constants

High Level Event

kHighLevelEvent = 23

Event Classes for Required Apple Event and Appearance Manager Apple Event

kCoreEventClass       = FOUR_CHAR_CODE('aevt')  // Event class - required Apple events.
KAppearanceEventClass = FOUR_CHAR_CODE('appr')  // Event Class - Appearance Manager 
                                                // Apple events.

Event IDs for Required Apple Events

kAEOpenApplication   = FOUR_CHAR_CODE('oapp')  // Event ID for Open Application event.
kAEReopenApplication = FOUR_CHAR_CODE('rapp')  // Event ID for Re-open Application Event.
kAEOpenDocuments     = FOUR_CHAR_CODE('odoc')  // Event ID for Open Documents event.
kAEPrintDocuments    = FOUR_CHAR_CODE('pdoc')  // Event ID for Print Documents event.
kAEQuitApplication   = FOUR_CHAR_CODE('quit')  // Event ID for Quit Application event.

Event IDs for Appearance Manager Apple events

kAEAppearanceChanged      = FOUR_CHAR_CODE('thme')  // Appearance changed.
kAESystemFontChanged      = FOUR_CHAR_CODE('sysf')  // System font changed.
KAESmallSystemFontChanged = FOUR_CHAR_CODE('ssfn')  // Small system font changed.
kAEViewsFontChanged       = FOUR_CHAR_CODE('vfnt')  // Views font changed.

Keywords for Apple Event Attributes

keyMissedKeywordAttr = FOUR_CHAR_CODE('miss')  // First required parameter remaining
                                               // in an Apple event.

Keywords for Apple Event Parameters

keyDirectObject = FOUR_CHAR_CODE('----')  // Direct parameter

Apple Event Descriptor Types

typeAEList    = FOUR_CHAR_CODE('list')  // List of descriptor structures.
typeWildCard  = FOUR_CHAR_CODE('****')  // Matches any type.
typeFSS       = FOUR_CHAR_CODE('fss ')  // File system specification.

Result Codes

errAEDescNotFound = -1701  // Descriptor structure was not found.
errAEParamMissed  = -1715  // Handler cannot understand a parameter the 
                           // client considers is required.

Theme Font ID Constants

KThemeSystemFont                 = 0
KThemeSmallSystemFont            = 1
KThemeSmallEmphasizedSystemFont  = 2
KThemeViewsFont                  = 3

Data Types

typedef FourCharCode  AEEventClass; // Event class for a high level event.
typedef FourCharCode  AEEventID;    // Event ID for a high level event.
typedef FourCharCode  AEKeyword;    // Keyword for a descriptor structure.
typedef ResType       DescType;     // Descriptor type.

typedef AEDesc        AEDescList;   // List of descriptor structures.
typedef AEDescList    AERecord;     // List af keyword-specified descriptor structures.
typedef AERecord      AppleEvent    // List of attributes and parameters for Apple event.

Descriptor Structure

struct AEDesc
{
  DescType descriptorType;  // Type of data being passed.
  Handle   dataHandle;      // Handle to data being passed.
};
typedef struct AEDesc AEDesc;

Keyword-Specified Descriptor Structure

struct AEKeyDesc	
{
  AEKeyword deskKey;      // Keyword.
  AEDesc    descContent;  // Descriptor structure.
};
typedef struct AEKeyDesc AEKeyDesc;

Functions

Creating and Managing Apple Event Dispatch Tables

OSErr  AEInstallEventHandler(AEEventClass theAEEventClass,AEEventID theAEEventID,
       AEEventHandlerUPP handler,long handlerRefcon,Boolean isSysHandler);

Dispatching Apple Events

OSErr  AEProcessAppleEvent(const EventRecord *theEventRecord);

Getting Data or Descriptor Structures Out of Apple Event Parameters and Attributes

OSErr  AEGetParamDesc(const AppleEvent *theAppleEvent,AEKeyword theAEKeyword,
       DescType desiredType,AEDesc *result);
OSErr  AEGetAttributePtr(const AppleEvent *theAppleEvent,AEKeyword theAEKeyword,
       DescType desiredType,DescType *typeCode,Ptr dataPtr,Size maximumSize,
       Size *actualSize);

Counting the Items in Descriptor Lists

OSErr  AECountItems(const AEDescList *theAEDescList,long *theCount);

Getting Items From Descriptor Lists

OSErr  AEGetNthPtr(const AEDescList *theAEDescList,long index,DescType desiredType,
       AEKeyword *theAEKeyword,DescType *typeCode,Ptr dataPtr,Size maximumSize,
       Size *actualSize);

Deallocating Memory for Descriptor Structures

OSErr  AEDisposeDesc(AEDesc *theAEDesc);

Accessing Theme Font Information

OSStatus  GetThemeFont(ThemeFontID inFontID,ScriptCode inScript,
          StringPtr outFontName,SInt16 *outFontSize, Style *outStyle);
OSStatus  UseThemeFont(ThemeFontID inFontID,ScriptCode inScript);

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »
Explore some of BBCs' most iconic s...
Despite your personal opinion on the BBC at a managerial level, it is undeniable that it has overseen some fantastic British shows in the past, and now thanks to a partnership with Roblox, players will be able to interact with some of these... | Read more »

Price Scanner via MacPrices.net

You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.