Route Scripts

Adding a routeScripts Slot to a newtApp Application

Let's add a Beep action as a routeScript to our Bookstore application. The completed project for different platforms (Mac OS, Windows 3.1 or Windows 95/NT) is available.

1. First, add a routeScripts slot to the newtApplication template:

[
   {
      title: "Beep",
         //   too lazy to create our own icon here
      icon: ROM_routeDuplicateIcon,
      routeScript: func(target, targetView)
      begin
         // plays a sound
         PlaySoundSync(ROM_plinkBeep);
      end,
   },
]
Once we've added this to our application, we can then tap the Action button. The results aren't entirely satisfactory, however. FIGURE 12.5 shows that we've got Beep, but Duplicate and Delete are no longer there (but at least Beep actually beeps when we tap it). We've lost them because the routeScripts slot found in the newtApplication proto contains items for duplicate and delete, but we overrode that slot in our template. We will have to fix this.

FIGURE 12.5 : The Action picker after adding a routeScripts slot.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996