background image
C H A P T E R 2 1
Routing Interface
21-24
Using Routing
Performing the Routing Action
21
The important slot in each frame in the
routeScripts
array is the
RouteScript
slot. This slot contains either a symbol identifying a method, or a
function directly, that is called if the user chooses this action from the Action
picker. This function is where you perform the routing action. The function you
define is passed two parameters, target and targetView, which define the data object
to be routed and the view that contains it, respectively.
The two values, target and targetView, are obtained from your application by the
Routing interface. As soon as the Action button is first tapped, the Routing interface
sends the Action button view the
GetTargetInfo
message to obtain these two
values. The
GetTargetInfo
method returns a frame containing these and other slots.
If you set up and use
target
and
targetView
slots in your views, you don't
need to implement the
GetTargetInfo
method because this is a root view
method that is found by inheritance. The root view method looks for the slots
target
and
targetView
, starting from the receiver of the message, which is the
Action button view. It returns these slots in a frame called the target information
frame. If you don't use these slots in your views, you'll need to implement the
GetTargetInfo
method to return them.
The
RouteScript
slot can contain either a symbol identifying a function or it
can contain a function directly. If you are defining the
routeScripts
array in a
registered view definition, the
RouteScript
slot must contain a function directly.
Alternatively, if your view definition is used only within your application, you can
specify an
appSymbol
slot in the
routeScripts
frame and specify a symbol
for the
RouteScript
slot. The
appSymbol
slot tells the system in what
application to find the method identified by the
RouteScript
slot. Using the
latter alternative ties the view definition to a single application.
Here is an example of how you might define the function identified by the
RouteScript
slot shown in the example frame above:
MyActionFunc: func(target,targetView) begin
targetView:DeleteStuffFunc(target);
end,
Handling Multiple Items
21
The target item, as returned by
GetTargetInfo
, may actually be a multiple-item
target object that encapsulates several individual items to be routed. You can check
if this is the case by using the function
TargetIsCursor
. If the target item is a
multiple-item target object, and you need to act separately on the individual items,
you can obtain a cursor for the items by using the function
GetTargetCursor
.
Then you can use the standard cursor methods
Entry
,
Next
, and
Prev
to iterate
over the cursor and return individual items. For more information about using
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна