Interacting With the User
When your application receives an Apple event, it may need to interact with the user. For example, it may need to display a dialog box asking the user for additional information or confirmation. You must use theAEInteractWithUser
function to make sure your application is in the foreground before it actually interacts with the user.Both the client application and the server application specify their preferences for user interaction. The
AEInteractWithUser
function checks the user interaction preferences set by each application. If both the client and the server allow user interaction,AEInteractWithUser
usually posts a notification request, and the Notification Manager brings the server to the foreground after the user responds to the notification request.The
AEInteractWithUser
function can also bring the server application directly to the foreground, but only if the client application is the active application on the same computer and has set two flags in thesendMode
parameter of theAESend
function: thekAEWaitReply
flag, which indicates that it is waiting for a reply, and thekAECanSwitchLayer
flag, which indicates that it wants the server application to come directly to the foreground rather than posting a notification request.To specify its preferences for how the server application should interact with the user, the client application sets various flags in the
sendMode
parameter toAESend
. The Apple Event Manager sets the corresponding flags in thekeyInteractLevelAttr
attribute of the Apple event.The server application sets its preferences with the
AESetInteractionAllowed
function. This function lets your application specify whether it allows interaction with the user as a result of receiving an Apple event from itself; from itself and other processes on the local computer; or from itself, local processes, and processes from another computer on the network.Your application calls the
AEInteractWithUser
function before interacting with the user. IfAEInteractWithUser
returns thenoErr
result code, then your application is currently in the front and free to interact with the user. IfAEInteractWithUser
returns theerrAENoUserInteraction
result code, the conditions didn't allow user interaction and your application should not interact with the user.The rest of this section explains how to set user interactions for the client and server applications and the practical effect these settings have when a server needs to interact with a user.
Subtopics
- Setting the Client Application's User Interaction Preferences
- Setting the Server Application's User Interaction Preferences
- Requesting User Interaction