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 thesendModeparameter to theAESendfunction. The Apple Event Manager automatically adds the specified flags to thekeyInteractLevelAttrattribute 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
kAECanInteractflag 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 thekAEAlwaysInteractflag, 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 thekAEAlwaysInteractflag, 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
kAENeverInteractor thekAECanInteractflag in thekeyInteractLevelAttrattribute 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 thekAENeverInteractflag as the default. If the server application is on the local computer, the Apple Event Manager sets thekAECanInteractflag as the default.In addition to the three user interaction flags, the client application can set another flag in the
sendModeparameter toAESendto 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
kAECanSwitchLayerflag 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, thekAEWaitReplyflag, must also be set in thesendModeparameter, and the client application must provide an idle function.The
kAEWaitReplyflag is one of three flags in thesendModeparameter 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
kAEWaitReplyflag, it should also provide an idle function when it callsAESendso 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 thekAENeverInteractflag in thekeyInteractLevelAttrattribute of the Apple event is set. (The Apple Event Manager sets this attribute according to the flags specified in thesendModeparameter ofAESend.) If thekAENeverInteractflag is set,AEInteractWithUserimmediately returns theerrAENoUserInteractionresult code. If the client specifiedkAECanInteractorkAEAlwaysInteract,AEInteractWithUserchecks the server's preferences for user interaction.