C H A P T E R 2 1
Routing Interface
Using Routing
21-23
Your application can provide internal application-defined actions, such as deleting
and duplicating, that do not use the Out Box and a transport to perform the routing
operation. These routing actions appear at the bottom of the Action picker.
You define these routing actions by providing a slot named
routeScripts
in
your application. The Action button searches its own context for the first
routeScripts
slot that it finds. Usually you define
routeScripts
in the base
view of your application. That way, all child views can find it by inheritance. But if
you want to have different routing actions active for different views, you can define
a
routeScripts
slot in each child view definition, where it will override the one
in the base view.
Alternatively, instead of defining an array of application-specific routing actions in
the
routeScripts
slot, you may want to build the array dynamically. To do this,
you can override the root view method
GetRouteScripts
, which is used by the
Routing interface to obtain the
routeScripts
array from your application. The
default version of this method simply returns the contents of the
routeScripts
slot to the Routing interface. In the
GetRouteScripts
method, build and return
an array like one you would define in the
routeScripts
slot.
If you provide a
routeScripts
slot, it must contain an array of frames, one for
each routing action item, that look like this:
{title: "MyAction", // name of action
icon: GetPictAsBits("MyActionIcon",nil), // picker icon
RouteScript: 'MyActionFunc, // called if action selected
// other slots and methods you need
...}
To include a separator line in the Action picker's list of application-specific routing
actions, include the symbol
'pickSeparator
in the
routeScripts
array
between the two items you want to separate. Alternatively, you can include a
nil
value to include a separator line.
For delete and duplicate actions, there are bitmaps available in ROM that you can
use as icons. For the
icon
slot of a delete action, you can specify the magic
pointer constant
ROM_RouteDeleteIcon
. For the
icon
slot of a duplicate
action, you can specify the magic pointer constant
ROM_RouteDuplicateIcon
.
If your application registers view definitions with the system, note that each view
definition can define its own
routeScripts
array. The routing action items that
apply to the individual view definition are added below those that apply to the
whole application in the Action picker. See the following section for more
information about specifying
routeScripts
in stationery.