links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Getting Started with Etoys / User Scripting
Last updated at 9:32 am UTC on 4 December 2017
User Scripting or "Etoys" is a powerful and simple visual scripting system built into Squeak. Scripts can be created using drag and drop for any Morphic object.

There are general Squeak images and Etoys specific images. In Etoys specific images the access to the Smalltalk level is not obvious.

Etoys image

An Etoys image is a Squeak image which has been configured specifically for Etoys work. These are the images downloadable from http://squeakland.org.

In an Etoys image have look at the "Quick Guides" in the Etoys help. Click on the question mark button or the help tab.


Then you get access to the Etoys quick guides.


General Squeak image

In Squeak 6.0a the Etoys code from Squeakland.org has been merged. But earlier versions of Squeak have Etoys support as well.

In such a general image you may work with Etoys in addition to the regular Morphic user interface.

There are two ways to create a new Morph: it can be drawn or created directly from code. Lets start with a drawing.

Drawing a Morph



An easier way to create a painting area is to click on the "Widgets" flap (bottom of screen) and drag out the painting icon.

When you are painting your morph, keep in mind that you have the entire painting canvas to make your morph on. Whatever is on the canvas will become your morph even if there are painted areas that don't touch!!

If your morph is not quite the way you want it after you clicked "Keep", you can edit it with the "repaint" option. To edit your morph:

You will now have an active paint tool to edit your morph with.

You may have also noticed several other options in the "painting" menu such as "rotational center". With "rotational center" you can set the center of rotation for your morph. The interesting part about this is that the "center" does not have to be on the area that you painted. It can be placed anywhere in the painting area !!!

Now that you have created the Morph object, we will need to open a viewer to start scripting it.

Opening a Viewer for your Morph Object


The viewer will now appear on the right side of the screen. On the top left corner of the viewer you will notice a small square with a picture of your morph in it. This is the Viewer tab. Clicking this tab will hide and unhide the viewer.

The top of the viewer has three icons and the name of the Morph. The top, left most icon, the "O", will close the viewer. The other "O"s will close their respective category. the next icon over that looks like miniature lines of text, will add another category pane to the viewer. The menu icon will display a menu with several options. The most important of which is "add a new instance variable". This menu option is the fastest way to add a new variable to your morph script. We will add an instance variable later on. Finally, the name of the morph object is displayed. The name of the Object can be changed simply by clicking the name twice to place a cursor and then typing the new name. You can confirm this by right clicking the object to get its halo. At the botoom of the halo will be the object's new name. You will also notice every line in the viewer now reflects the name change.

Missing File (/squeak/uploads/viewer.jpg)

The first pane from the top is the "search" pane. It allows you to find any word in any of the category panes whether the pane is visible or not (more on that later). Let's give it a try.
Two new lines will appear which are from the Geometry category.
The remainder of the viewer consists of category panes. These panes can be closed by clicking it's "O" icon. It's category can be changed by clicking the up/down triangles or by clicking the category name and choosing a new one from the list. The remainder of the category panes are filled with commands.

Let's create a new script and start using some commands !

There are two ways to create a new script.


Click and drag any command from any category to the desktop. Commands need to be dragged from the middle (eg. click on "make sound" or "forward by") to pick them up.

A "scripts" category pane will appear in the viewer and your script window will appear on the desktop.