// Text of project WakeUpAndGoToSleep written on 5/12/95 at 17:50 // Beginning of text file Project Data /* 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. */ InstallScript := func(partFrame) begin AddDeferredAction(func() AddPowerOffHandler(GetRoot().(kAppSymbol)),[]); end; RemoveScript := func(partFrame) begin RemovePowerOffHandler(GetRoot().(kAppSymbol)) end; // End of text file Project Data // Beginning of file WakeUpAndGoToSleep.t // Before Script for "_view000" // Copyright © 1994-1995 by Apple Computer, Inc. All Rights Reserved. _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"); Self:Close(); Self:Open(); end, nWakeUps: 0, _proto: @157 }; constant |layout_WakeUpAndGoToSleep.t| := _view000; // End of file WakeUpAndGoToSleep.t