// constants that this project can use... // screen size maximums for this application constant kMaxWidth := 240 ; constant kMaxHeight := 336 ; // ---- End Project Data ---- // ---- File UndoRedo.t ---- // Before Script for "undoExampleApp" // Copyright © 1993,4 Apple Computer, Inc. All rights reserved. undoExampleApp := {title: "Undo/Redo Example", viewBounds: {top: 0, left: 0, right: 240, bottom: 336}, undoMethod: func(oldText) begin // can't call AddUndoAction within an undo function, so we use // AddDeferredAction to get it added later. AddDeferredAction(redoMethod, [myButton.text]); SetValue(myButton, 'text, oldText); end, redoMethod: func(oldText) begin AddUndoAction('undoMethod, [oldText]); end, viewQuitScript: func() begin // clear all pending undo actions from the // undo stacks. See the Q&A. // Need to do this to avoid the Newton still needs card // dialog. ClearUndoStacks(); end, viewSetupFormScript: func() begin // resize application to display, but // make sure it is no bigger than // a MessagePad b := GetAppParams() ; viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop, MIN(b.appAreaWidth, kMaxWidth), MIN(b.appAreaHeight, kMaxHeight)); end, _proto: protoApp, debug: "undoExampleApp" }; myButton := /* child of undoExampleApp */ {text: "X", viewBounds: {left: 26, top: 50, right: 194, bottom: 98}, buttonClickScript: func() begin // add an undo action to the undo stack // An undo will result the undoMethod // message being sent to this app, with // one argument (the old text of this // button). AddUndoAction('undoMethod, [text]); // change the text of this button SetValue(self, 'text, text & "+") ; end, viewFlags: 515, _proto: protoTextButton, debug: "myButton" }; // View myButton is declared to undoExampleApp // ---- Beginning of section for non used Layout files ---- // End of output