tips
[Top] [All Lists]

REALbasic Tip: Subclassing windows

To: REALbasic-tips at lists dot realsoftware dot com
Subject: REALbasic Tip: Subclassing windows
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Tue, 27 Jul 2004 10:41:54 -0500
Cc:
Delivered-to: REALbasic-tips at lists dot realsoftware dot com
It doesn't happen often but when you need several windows to share the same functionality, there's a good trick you should be aware of. You can create a new class that will hold the methods and properties your windows need to share and then make your windows subclasses of this new class. To subclass a window, do this:

1. Add a new class to your project.
2. Choose "Window" as its super class in the properties window.
3. Add the methods and properties that you need to share among several other windows.
4. Set the super of the other windows to your new class.

You will see that your windows now all have access to the methods and properties of the new window class you created.

One example of where this can be useful is when you have a documented-based application with several windows that are all different editors of a document. A good example of that is REALbasic itself. There are many different windows that all edit your project. You can put the common code into a window class then make the various editor windows subclasses of the common code window class.
--
Geoff Perlman
President and CEO
REAL Software, Inc.

<Prev in Thread] Current Thread [Next in Thread>
  • REALbasic Tip: Subclassing windows, Geoff Perlman <=