At Your Service

Prepress AutoTools



App Glue


In The News

Contact Info


Macrobyte Resources

Tonto Documentation

Registering a Script

Scripts are registered with Tonto through an AppleEvent, but you don't have to worry about that. Just send the script (as a string) to suites.Tonto.registerScript.

registerScript( ) takes four parameters.

  • First is the caption, or label, for the script-button being created.
  • Second is the script itself, in string form.
  • Third is the 'set' that the script belongs to.
  • Fourth is an icon ('cicn') ID or Name.

Tonto.registerScript( "Tile Windows", "workspace.tileWindows( )", 'LAND', "tonto feather" )

Back to top.

Registering a List of Scripts

To register a group of scripts all at one time (which is much faster than registering them all separately), you'll use two verbs.

The main verb is tonto.registerList(), which takes one parameter: a list of records, in which each record describes a single script to be registered.

The records that must be provided as items in the list (sent to registerList) can easily be created by using tonto.utils.getRecord( ).

utils.getRecord( ) takes four parameters which are identical to those sent to tonto.registerScript

  • First is the caption, or label, for the script-button being created.
  • Second is the script itself, in string form.
  • Third is the 'set' that the script belongs to.
  • Fourth is an icon ('cicn') ID or Name.

local ( ls = true );
ls[ 0 ] = tonto.utils.getRecord( "Tile Windows", "workspace.tileWindows( )", 'LAND', "tonto feather" );
ls[ 0 ] = tonto.utils.getRecord( "Close Window", "window.close( window.frontmost( ) )", 'LAND', 149 );
ls[ 0 ] = tonto.utils.getRecord( "Actv Frontier", "frontier.bringToFront( )", "global", 150 );
tonto.registerList( ls )

Back to top.

Removing a Script (unregistering)

The easiest way to remove a script button from the pallette is simply to command- click on the button. It will be removed instantly.

To allow you to automate the removal of buttons (i.e. to unregister scripts), an Apple Event has ben provided. To unregister a script from Frontier, call tonto.unregisterScript( ) with two parameters: the caption or index of the button you'd like removed, and the name of the set from whnich it should be removed.

Tonto.unregisterScript( "Tile Windows", 'LAND' )

- or -

Tonto.unregisterScript( 3, "general" )

Back to top.

Working With Sets

Sets are groups of scripts, associated with a specific application. The name of a set must be four characters long, and is the creator code (signature) of the associated application. The buttons for the scripts in a set will only be visible when the associated application is frontmost.

There is also a global set, named, appropriately, "global". If no set is specified when you call tonto.registerScript(), then the script will be added to the global set. All of the buttons for the global set are always visible.

You can have any number of script sets. At this time, a script set can only contain 10 scripts (10 buttons).

Back to top.

Adding Icons

You can add your own set of icons to Tonto, without changing the Tonto application. We've included a file called "Tonto Icons". Make sure that it's in the same folder as the Tonto application file.

Any cicn resources in that file are automatically available for use on the buttons, and they can be specified by name or by id number.

It is strongly recommended that you only use icons which are 16 x 16 pixels.

Back to top.

Caching Scripts

Most likely, you'll want to register the same scripts every time. As of Tonto 1.0a4, the scripts are cached in menubar objects, in user.tonto. See tonto.#sampleCache for an example.

All that you need to remember, to use the caching mechanism, are the following points:

  • The first summit of the menubar is the name of the cached set. So, the actual name of the menubar object does not matter.
  • All cached script entries in the menubar must be indented below the first summit.
  • The text of a menubar entry is the "caption" for the script.
  • If the caption text contains a comma, then the text before the comma will be used to (attempt to) identify which icon belongs with this script. Numbers (resource ID's) or icon names may be used.
  • The script of an item in the menubar is the script which will be registered with Tonto. So, just type your script in as you would type any script.

The benefits of this caching mechanism are two:

  • You can arrange the order of the buttons however you like, by simply dragging the entries in the menubar (before registering the cached scripts).
  • It's easy to edit and debug the cached scripts, because you can use Frontier's standard script-editing environment (instead of editing strings, which the old cache system requred).

Back to top.

Site last updated Tuesday, August 17, 1999
Contact Macrobyte Resources with comments or questions. Broken links, or other problems with the site? Please write to the Webmaster.