Real Logo
REALbasic Home
Thank you for trying this tutorial ... It is not associated with REAL Software.     powered by ... a desire to share

Introduction to REALbasic for the Mac

space space
space Contents
What You Should Know
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9

My RB Samples
space spacespace
space space
Lesson 6: Were Going In ...
by Thomas J. Cunningham

  space space

Getting A Little Deeper ...
6. The Code Editor.

I would like to go a little deeper in to the programming interface of REALbasic, the Code Editor. The Code Editor is just like it sounds. This is where we start taking more control of our "house" project. Instead of letting REALbasic do all of the work, we are going to take a little responsibility for how our project operates.

Launch RB and create a new project (Command N). Close the "Untitled" window and you will see our project window in the middle of the screen ( unfortunately, it is not labeled as "project") also titled "Untitled". You see two items in the project window, Window1 and Menu. Notice too the Tools window and the Properties window we used in the previous lesson.
We want to open the Code Editor for Window1. You can accomplish this in two ways. If you double click "Window1", your main window opens up. Double click again anywhere in this window and poof, our Code Editor appears. The second way is to highlight Window1 in the projects window and press Option-Tab. Either way is just fine.


Lets examine the Code Editor. First of all, notice that the Tools window (to the left) and the Properties window (to the right) on your screen are gone. Well, they closed. Why would this be? This has to do with the nature of the how RB interacts with you the user. This is RB's user interface and it is one of many simply elegant features that help you the beginner programmer.
The Code Editor is for entering your instruction code. The editor is like a word processor. You enter text. The Tools window and the Properties window are associated with the graphics or drawing nature of our applications window (Window1) and not the code editor, so they are conveniently closed for you. You do not drag a class from the Tools window in to your Code Editor, so why have its window cluttering up your screen ?

Our Code Editor window is labeled (Code Editor (Window1)). To the left are five Handlers. They are: Controls, Events, Menu Handlers, Methods and Properties. Each handler, along with its groovy little icon, has a little disclosure arrow next to it. If you click on each of the five arrows, you will find that at this stage of our project, only the Events handler arrow reveals more details.

In this exercise we are going to duplicate what we did in Chapter Five, except we are going to do it by writing our own code. Close the Code Editor window, double click Window1 in the project window. Grab our StaticText class from the Tools window on the left (the letter "A") and place it in to Window1 as before.
Close Window1 and hit Option-Tab to reveal the window's Code Editor again. Now click on the disclosure arrow next to Controls. Hey, it's not empty now, but it shows StaticText1, its little icon and its own little disclosure arrow. How come? Apparently our StaticText class is a Control handler. And ..... so what and what does that mean you mutter to yourself !
Lets ask RB for some help with this. Hit Command-1. Our Online Reference appears. Let me make this clear again, this reference should become your friend, your buddy, your companion while you learn this stuff. Use it often!
Click on the "Alpha" heading on the top left side of the reference window (this means: alphabetize the list) . Scroll down until you see "StaticText Control" and click on the word. To the right you will see more info than you really want to know at this point, but hang in there ! Remember we are here in the RB reference area to get some insight in to why our StaticText Class, that we dragged into our window, is now listed as a Control Handler in the Code Editor. Click on the blue underlined link RectControl under the Super Class heading. Our StaticText Class is associated with a RectControl Class. Read through the brief explanation at the top. Next, click on Control link under the RectControl Class Super. We now see details and explanations of a Control Class. Gosh, where does this all end ! Soon. Click once more on the Object link and thank goodness this is what is referred to as our Base Class.

A very loose analogy or two is in order.
Your shoes are a part of your clothing , your clothing is a part of you a human being, a human being is a part of mankind, mankind is a part of earth and earth is apart of the universe. The universe is our base class. Our shoes behave under the same rules of physics as the universe. Our shoes inherits and shares the physical properties from the universe.
A piece of wood is a part of a door, our door is a part of a wall, our wall is a part of our house and our house is a part of our city. Our city is the base class of our piece of wood.

This concept in programming is called Class Inheritance. A StaticText Class inherits or has the same abilities and properties as does its Super Classes. Class inheritance is a foundation and a corner stone of object oriented design programming.
And to get back to our example (finally!) , every thing (or Class to be more accurate), you drag from the Tools window to your application window will be listed as a Control Handler in the Code Editor because they are associated with the Control Class. These Controls are elements of your window.
The other four Handlers can be thought of as being associated with the application itself. This keeps things neat and tidy and also supports another corner stone that RB supports, the concept of Objects.
An Object may be defined as an instance of a class, a unit that has a unique identity separate from its' collection of values.

Chapter 7


Your REALbasic (RB) Learning Library and Reminders

Explore the On-Line Reference that comes with RB by hitting Command-1. Drag one of the classes from the Tools window in to a Project window. Look at the Properties window to the right of your screen, note its name, then look it up in the reference.

This is your way to explore the abilities and the language of programming. You need to educate yourself on what the abilities of the RB environment are. How are you going to know what you can use RB to do unless you know what it can do in the first place ? !

This also leads you to the powerful learning tool of downloading other people's RB projects and reading through them. Most, some, or all of it might be over your head, but at least you are seeing what some of the building blocks of the program are capable of doing. And who knows, maybe some of it will stick in the mud between your ears. * SMILE *


  1 | 2 | 3 | 4 | 5 | 6 |   7 | 8 | 9 |

Find This Useful / Not ? Email Me :

Copyright 2001,Thomas J. Cunningham