beautypg.com

Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 780

background image

C H A P T E R 2 1

Routing Interface

21-32

Using Routing

Data” (page 21-34). If a matching application is found in the registry, the

appSymbol

slot of the item is set to the value of the

appSymbol

slot in the

matching application. If no matching applications are found in the registry, the item
may have a pre-existing

appSymbol

slot, which determines the application to

which it belongs. If no matching application is located in the registry and the item
has no existing

appSymbol

slot, it cannot be put away automatically.

Next, the In Box checks for an

AutoPutAway

method in the base view of the

application whose

appSymbol

slot matches that in the item. If the

AutoPutAway

method exists, the In Box sends the

AutoPutAway

message to the application,

passing the incoming item as a parameter. In this way, items can be automatically
transferred to an application, with no user intervention.

If the

AutoPutAway

method returns

nil

, this signals that the item could not be

put away and the item is left in the In Box.

If the

AutoPutAway

method returns a non-

nil

value, it is assumed that the

application handled the item. The item is either saved in the In Box or deleted from
the In Box, depending on the user’s preference.

If your application implements the

AutoPutAway

method, it can inform the

system of this fact when it is installed, to receive any items that may have arrived
for it while it was uninstalled. In the application part

InstallScript

function,

call the global function

AppInstalled

to let the system know that the

application is present. The

AppInstalled

function prompts the In Box to send

an

AutoPutAway

message to the application for each In Box item that may have

arrived for the application before the application was installed. Note that you must
call the

AppInstalled

function using a deferred action, like this:

AddDeferredCall(GetGlobalFn('AppInstalled),[kAppSymbol]);

This feature is useful in cases where the application resides on a card that is not
always installed in the system. Messages are held in the In Box while the application
is not installed, and then when it is installed, those received messages are sent to the
application with the

AutoPutAway

message.

The item passed to your application’s

AutoPutAway

method is the entry from the

In Box. It has several slots that are used by the In Box or the transport. The data
your application uses is contained in the

body

slot.

If the item was sent by a custom transport that sends multiple-item target objects
(such as those created by

CreateTargetCursor

), you might need to check if

the body slot contains such an object by using

TargetIsCursor

. If so, you can

get a cursor for the object by using

GetTargetCursor

, and then iterate over the

cursor to handle individual items.