Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

PDF:

Feature

One, Two, Undo

Adding the Undo command to your REALbasic project

Issue: 1.2 (October/November 2002)
Author: Scott Forbes
Author Bio: Scott Forbes is an engineer-turned-project manager for Lucent Technologies in Sydney, Australia. He learned to program in 1982 on a Radio Shack TRS-80 Model III, and it's been downhill ever since.
Article Description: No description available.
Article Length (in bytes): 35,299
Starting Page Number: 16
RBD Number: 1110
Resource File(s):

Download Icon 1110.sit Updated: Friday, October 17, 2003 at 12:19 PM

Related Web Link(s):

http://www.ravenna.com/~forbes/~yonk/source/

Known Limitations: None

Excerpt of article text...

You've almost finished your first "serious" REALbasic project, the one you might someday publish. You've learned the language, you understand the fundamentals of object-oriented programming, and you've written the core of your application. Now all you need are the finishing touches: An About box, an icon or two... and, of course, you need an Undo command.

Undo is often the last feature we think about as developers, but as users it's the first feature that we notice is missing. Undo can be difficult to implement, especially if we've already written the rest of the code, because the command needs to know about every "undoable" action that occurs throughout the program.

What we need is a flexible approach to writing an Undo command, that we can add to existing projects easily -- ideally one that we can re-use and expand as needed. By following the principles of object-oriented design, we can develop an Undo system that meets our needs.

Choosing What To Undo

Before we start coding Undo, our first step is to decide what actions to make undoable. We can look at our program as a set of actions, most of which happen in response to user input -- but some actions are too trivial to undo, some can't be undone, and in some cases we may choose to be unforgiving. We wouldn't undo a mouse click in a ScrollBar, for example, and we can't undo sending an e-mail message; we might not allow undo after a wrong move in an arcade game.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com