Important: The information in this document is obsolete and should not be used for new development.
Setting the Client Application's User Interaction Preferences
The client application sets its user interaction preferences by setting flags in thesendMode
parameter to theAESend
function. The Apple Event Manager automatically adds the specified flags to thekeyInteractLevelAttr
attribute of the Apple event. These flags are represented by the following constants:For example, suppose a client application sends a Set Data event to a database application to change a customer's address. The database application is configured to request user confirmation of changes to a customer's record. In this case the client sets the
kAECanInteract
flag before sending the event. Thus, the database application attempts to interact with the user if interaction is allowed. If interaction is not allowed, the database makes the correction anyway without consulting the user. However, if the client application sends a Delete event to delete a customer's record entirely and sets thekAEAlwaysInteract
flag, the database application deletes the specified record only if it can interact with the user first and receives confirmation of the decision to delete a record. If interaction with the user is not allowed, the database application returns an error. By setting thekAEAlwaysInteract
flag, the client application ensures that the entire record won't be lost if the user sends the Delete event by mistake.If the client application doesn't specify any of the three user interaction flags, the Apple Event Manager sets either the
kAENeverInteract
or thekAECanInteract
flag in thekeyInteractLevelAttr
attribute of the Apple event, depending on the location of the server application. If the server application is on a remote computer, the Apple Event Manager sets thekAENeverInteract
flag as the default. If the server application is on the local computer, the Apple Event Manager sets thekAECanInteract
flag as the default.In addition to the three user interaction flags, the client application can set another flag in the
sendMode
parameter toAESend
to request that the Apple Event Manager immediately bring the server application directly to the foreground instead of posting a notification request:Note that although the
kAECanSwitchLayer
flag must be set for the Apple Event Manager to bring the server application directly to the foreground, setting it does not guarantee that the Apple Event Manager will bypass the notification request if user interaction is permitted. Another flag, thekAEWaitReply
flag, must also be set in thesendMode
parameter, and the client application must provide an idle function.The
kAEWaitReply
flag is one of three flags in thesendMode
parameter that a client application can set to specify whether and how the client should wait for a reply. (For a description of these flags, see "Sending an Apple Event and Handling the Reply" on page 3-25.) If the client application is not waiting for a reply, the user may have continued with other work. An application switch at this point might be unexpected and would thus violate the principle of user control as described in Macintosh Human Interface Guidelines.If the client application sets the
kAEWaitReply
flag, it should also provide an idle function when it callsAESend
so that it can handle events such as update events that it receives while waiting for the reply. Idle functions are described in "Writing an Idle Function," which begins on page 5-22.When a server application calls
AEInteractWithUser
, the function first checks whether thekAENeverInteract
flag in thekeyInteractLevelAttr
attribute of the Apple event is set. (The Apple Event Manager sets this attribute according to the flags specified in thesendMode
parameter ofAESend
.) If thekAENeverInteract
flag is set,AEInteractWithUser
immediately returns theerrAENoUserInteraction
result code. If the client specifiedkAECanInteract
orkAEAlwaysInteract
,AEInteractWithUser
checks the server's preferences for user interaction.