beautypg.com

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

Page 716

background image

C H A P T E R 1 9

Built-in Applications and System Data

19-42

Icons and the Extras Drawer

Creating a Script Icon

19

Installation of a script icon is basically the same as that for a soup icon. The two
main differences are that the symbol

'scriptEntry

is passed in for the iconType

parameter of

AddExtraIcon

, and the paramFrame argument contains different

slots. However, with a script icon it is not important to keep this icon in the internal
store. Instead, you should ensure that the icon is installed on the same store as the
package with which it is associated.

The most likely use for a script icon is for a transport to bring up an interface for
user preferences. The code sample shown below brings up a such a slip:

//Useful constants.

DefConst('kMyConfigSlipSym,

Intern("configSlip:" & kAppSymbol));

constant kScriptIconName

:= "ScriptIcon Slip";

constant kScriptIconPkgName:= Intern ("Script:" &

kAppSymbol);

// get the icon picture

r := OpenResFileX(HOME & "pictures");

DefConst('kMyScriptIcon, GetPictAsBits("TARDIS", nil));

CloseResFileX(r);

// the tap action, small and simple

DefConst('kTapScript, func()

GetGlobalVar(kMyConfigSlipSym):Open() );

DefConst('kScriptIconParamFrame,

{

// name in the Extras Drawer

text: kScriptIconName,

// icon in the Extras Drawer

icon: kMyScriptIcon,

// to allow access via SetExtrasInfo

app:kScriptIconPkgName,

// function to call when icon is tapped

tapAction: kTapScript

}

);