If you don't already have the Squeak system on a computer that you can use, download and install it now! Launch Squeak.
Smalltalk, from which Squeak is derived and with which it is still somewhat compatible, was designed assuming a three-button mouse. If your mouse has fewer buttons, you must press extra keys with the mouse button or buttons to simulate the mouse buttons that you are missing.
For platform independence, the mouse buttons are usually referred to by colors in the Squeak software and documentation. Consider buying a 2 or 3-button mouse; they are quite inexpensive, and make the Squeak world much more friendly. (They are pretty useful in many other applications too!) Software that comes with the mouse, or that is available on the Internet, will let you set up the buttons so that they do the right thing. (I highly recommend USB Overdrive for the Mac.)
Squeak also has some built-in options for customising the mouse and the meta keys on your keyboard. Try open >> preferencs from the world menu, and search for swap. The swapMouseButtons preference switches the yellow and blue functions.
The following chart shows what keys must be held down when mouse-clicking to simulate Squeak's buttons.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
My mouse also has a scrolling wheel. I have this set up so that
"wheel up" maps to
-upArrow
(on my Macintosh) and "wheel down" maps to
-downArrow.
This lets me use the wheel to control scrolling in my Squeak
windows.
One of the advantages of referring to the buttons by colors is that you may choose to map them to different physical buttons from those shown above. For example, if you are left-handed, you might choose to reverse the red and blue buttons. On my mouse, the middle button is actually the scrolling wheel. Because the yellow button is used very frequently, I prefer to put the yellow button on the right, and to put the blue button on the wheel in the middle.
Placing some colored labels on the mouse buttons will help your fingers to follow these directions.
Red-click outside of any window; you will see the world menu. Notice that most Squeak menus are not modal; you can leave them on the screen for as long as you wish by selecting keep this menu up. Do this. Also, notice that menus appear when you click the mouse, but do not disappear when you release it; they stay visible until you make a selection, or until you click outside of the menu. You can even move the menu around by grabbing its title bar.
Bring up the open... submenu and select workspace. You should get a grey-boardered window labeled Workspace.
When you start Squeak for the first time, the Squeak Virtual Machine is loaded with an image file, which contains an initial set of objects, including a vast amount of pre-existing code and programming tools (all of which are objects). You will modify these objects during your Squeak session.
When you terminate Squeak, you will save a snapshot of your memory containing all of your objects. The next time you use Squeak, memory will be reloaded from this file and the state of the system will be exactly as you left it. The snapshot file will be named xxxxx.image, where xxxxx is something you will choose, like Tutorial.image. There will be a corresponding "changes" file, with a name such as Tutorial.changes.
Each window has a title bar with a "close" icon (an
x) in the upper left and a
"collapse"
icon
in the upper right.
FillInTheBlankMorph.) Experiment with
full screen, and with changing the stacking order. Select
window color; the system is now waiting for you to select a
color for the window. Position the mouse anywhere on the screen
and click it to select a color.ifTrue:. To type these capitalized shortcuts you
can hold down shift and the shortcut key while you type
t, or, more conveniently, you can hold down ctrl
while you type t.|
Key |
|
Notes |
|
z |
Undo |
|
|
x |
Cut |
|
|
c |
Copy |
|
|
v |
Paste |
|
|
a |
Select all |
|
|
D |
Duplicate. Paste the current selection over the prior selection, if it is non-overlapping. |
1 |
|
e |
Exchange. Exchange the contents of current selection with the contents of the prior selection |
1 |
|
y |
Swap. If there is no selection, swap the characters on either side of the insertion cursor, and advance the cursor. If the selection has 2 characters, swap them, and advance the cursor. |
|
|
w |
Delete preceding word |
|
2+3 in the
workspace, select it and then select the print it menu
option, or type command-p. (Print it and do
it work on the selected text, but if there is no selection,
they work on the whole of the current line.) Both commands
evaluate the selected expression. The print it command
displays the result, but the do it option doesn't display
the returned value. The short-cut key for do it is
command-d. These are very common actions, so practice the
shortcut keys.
|
Key |
|
|
d |
Do "it" (where "it" is a Squeak expression) |
|
i |
Inspect "it": evaluate "it" and open an inspector on the result. ("it" is a Squeak expression). Exception: in a method list pane, i opens an inheritance browser. |
|
p |
Print "it". Evaluate "it" and insert the results immediately after "it." (where "it" is a Smalltalk expression) |
|
I |
Open the Object Explorer on "it" (where "it" is an expression) |
|
Key |
Description |
|
f |
Find. Set the search string from a string entered in a dialog. Then, advance the cursor to the next occurrence of the search string. |
|
g |
Find again. Advance the cursor to the next occurrence of the search string. |
|
h |
Set Search String from the selection. |
|
j |
Replace the next occurrence of the search string with the last replacement made |
|
A |
Advance argument. Advance the cursor to the next keyword argument, or to the end of string if no keyword arguments remain. |
|
J |
Replace all occurrences of the search string with the last replacement made |
|
S |
Replace all occurrences of the search string with the present change text |
|
Key |
|
|
l |
Cancel (also "revert"). Cancel all edits made since the pane was opened or since the last save |
|
s |
Accept (also "save"). Save the changes made in the current pane. |
|
o |
Spawn. Open a new window containing the present contents of this pane, and then reset this window to its last saved state (that is, cancel the present window). |
Spline example, select it
and do it. Use the red button to click off several points on the screen. Then click another button: you should see a curve. What does world menu >> restore display do to the curve? Can the curve
lie inside a window? What do scroll bars do to the curve?
Why?Spline example1, then select do
it. This is a typo and you should see a window pop up. Push
the Abandon button. (example1 is a valid
message, just not for Splines.)Spline exampl then do it. This is
also a typo, but this time Squeak suggests some possible
corrections. Select cancel or example. (Here
exampl is not a valid message on any object, so the
system looks for messages with similar spellings.)
The System Browser is the main tool used to read and write code in Smalltalk. It is OK to have many System Browsers open at once. Normally, if you change code in one Browser, the changes will be visible in any other. (Preferences >> smartUpdating controls this).
even method in class Integer. How does
this method determine its result?Paths are collections of points used to represent geometric shapes.
There are two ways to type the assignment operator. You may either
type colon-equal (like Pascal) or you may use the left arrow, which
in Squeak replaces the underscore character. In other words, type the
_ key and see
on the display.![]()
100@100 specify
Points; the @ character is a binary infix operator.
For example 20@500 means the point with x=20 and y=500.f
Form
fromUser. The cursor will change to an 90° angle; use
this to select a rectangle from the screen.f displayAt: 100 @ 100.f displayAt: Sensor waitButton. Click the
mouse button. p := Path fromUser. Then
choose a blank piece of screen and click on several points in a
rough circle using the red mouse button. Each time that you click,
you will leave behind a small red dot. When you have enough
points, click with one of the other mouse buttons. (The dots will
disappear.)fromUser to the class object Path. The
answer is a new instance of Path, which we assign to the temporary
variable p.p
Path fromUser. (Same statement, just use the left-arrow
this time.) p displayAt: 10 @ 0. The red dots should reappear, offset 10 pixels to the right of where you first drew them.Color
blue, Color is a class, and so is capitalized,
while blue is a message sent to that class, and so is
lower case. Also, vertices: color: borderWidth: borderColor:
is a bit of a mouthful, so type vertices and
then use command-q completion. ctrl-a will move the
cursor from one argument position to the next.
m
PolygonMorph
vertices: p color: Color blue borderWidth: 1 borderColor: Color
black.
m openInWorld
m
PolygonMorph
..., creates a new PolygonMorph and names it
m. The second line tells m to display
itself in the World, that is, on the screen. A blue
PolygonMorph will appear on the screen.polygon879. This
provides you with a way of referring to the morph. Of course, you
already happened to have a name for your morphm. So
m and polygon879 should both be names
for the same object. Let's check this: do a print it on
polygon879 == ma == b tests whether a and
b are the very same object. This expression should
print as true.
m color: Color redThe morph will change color.
m openInWorld again. The
morph (still red) will reappear.