beautypg.com

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

Page 638

background image

C H A P T E R 1 7

Additional System Services

17-22

Using Additional System Services

initialSetup: // used to initialize view automatically

{

name: 'vMyBarber,

appSymbol: kAppSymbol,

values:

{

icon: kDummyActionIcon,

statusText: "Computing IsHalting…",

closeBox: func()

begin

base:Hide(); //close the status view

//add an action to the Notify Icon, this allows

//the user to reopen the status view, which is

//necessary to allow the user to cancel the

//operation... (we save a reference to the

//action in the app base view to kill later)

GetRoot().(kAppSymbol).theNotifyIconAction :=

GetRoot().notifyIcon:AddAction(

"IsHalting",kNotifyCallbackFunc,nil)

//the notify icon will need this reference to

//the status slip

GetRoot().(kAppSymbol).theStatusSlip := base;

end;

}, //values

}, //initialSetup

} //myStatusTemplate

We defined

kNotifyCallbackFunc

at compile time, so as to avoid creating

run-time functions (closures) as:

DefConst ('kNotifyCallbackFunc,

func()

begin

if not Visible ( GetRoot().(kAppSymbol) ) then

GetRoot().(kAppSymbol):Open();

GetRoot().(kAppSymbol).theStatusView:Show();

//won't need any more

GetRoot().(kAppSymbol).theStatusView := nil;

end);