/* Copyright: © Apple Computer, Inc. 1993 author: Mike Engber WakeUpAndGoToSleep v1 This sample demos how to detect when the Newton wakes up. The basic idea is to spawn a deferred action right before the Newton goes to sleep. The action runs when the Newton wakes up. This sample replaces WakeUpTimeToDie which used a more complex method involving idle scripts. */ constant kAppSymbol := '|WakeUpAndGoToSleep:PIEDTS|; InstallScript := func(partFrame) begin AddDeferredAction(func() AddPowerOffHandler(GetRoot().(kAppSymbol)),[]); end; RemoveScript := func(partFrame) begin RemovePowerOffHandler(GetRoot().(kAppSymbol)) end; // ---- End Project Data ---- // ---- File WakeUpAndGoToSleep.t ---- _view000 := {title: "no wake-ups yet", viewBounds: {left: 0, top: 10, right: 108, bottom: 118}, viewFormat: 83951953, powerOffScript: func(what) begin if what = 'powerOff then AddDeferredAction(func() GetRoot().(kAppSymbol):MyPowerOnScript(),[]); //need to return true when called with 'okToPowerOff - so we always return true true; end, MyPowerOnScript: func() begin //I chose the name MyPowerOnScript in case a future system // supports PowerOnScript (which would be useful) nWakeUps := nWakeUps + 1; SetValue(self,'title, nWakeUps && "wake-ups"); end, nWakeUps: 0, _proto: protoApp }; // ---- Beginning of section for non used Layout files ---- // End of output