FLOSS Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

Etoys Reference Manual Vol. II

Accessing Squeak from Etoys

Much of Etoys is intended to provide a purely graphical programming environment for children, but there are several places where Squeak is accessible. These include introspection and development tools available on menus and through keyboard shortcuts, and a text scripting facility within the graphic scripting tile system. The next chapter describes the introspection and development tools. This chapter describes the other parts of the Etoys-Squeak interface, including extensions to Etoys that are hidden from the novice.

Etoys Extensions

Etoys is set up by default to provide direct access to only a subset of its facilities to the beginner. The following items in the Preferences panel control access to extra facilities.

eToyFriendly preference

The eToyFriendly preference is in the scripting category of Preferences. It controls a large number of settings, documented in a separate Appendix. When it is on, as it is by default, error handling is simplified, making the debugger not directly accessible. Many menu items and some Standard Viewer categories are not provided to the user unless this preference is turned off.

debugHandle preference

With the eToyFriendly preference turned off, the debugHandle preference in the halos category controls display of the debug Halo handle, which gives access to the menu shown below. The tools on this menu are described in the Etoys/Squeak Development Environment chapter.

Particular Etoys objects will have more or fewer choices on this menu, and it is different in different versions of Etoys. Clicking control-menu brings up this even more extensive supplementary menu, which offers several submenus. Some of these commands are described in the User Interface chapter of the first volume of this manual, while the development tools are described in the Etoys/Squeak Development Environment chapter in this volume.


Scripting in Squeak

The Script Editor menu contains the option show code textually. In V4,

and in V5,

 

This command translates the current program from tiles to Squeak text. For example:

When a script is in text form, the Script Editor menu offers the command revert to tile version, which always works if there has been no change to the text, and can revert some changes that conform to the tile definitions.

The user can edit the text version of a script freely, even discarding the original program and starting fresh in Squeak.

The current object is referred to as self within any of its scripts. Other objects can be referred to by name within a text script. The trick is to determine the relevant name from among several associated with the object. The name given in the halo does not usually work. An object named Rectangle in its halo may be Rectangle1 in scripts, and an object named Rectangle1 in its halo my be Rectangle2 in scripts. The Player and Costume names given in the object Inspector accessed within Players are also irrelevant to scripting. The best way to find the name of an object for use in scripts is to look in a script.

Let us continue with the example of the Ellipse and the Rectangle above, and create a script for the Ellipse that says, in tiles,

Ellipse script
Ellipse forward by 5
Rectangle forward by 5

On translation to text, this becomes

Ellipse script
script
   self forward: 5.
   Rectangle1 forward: 5

Thus this particular Rectangle has to be referred to in scripts defined for other objects as Rectangle1.

Access to Squeak Objects in Etoys

With eToyFriendly turned off, an additional category appears in any StandardViewer, called As Object. It gives partial access to the Squeak implementation of an Etoys Morph. This menu is documented in the Common Tiles chapter in Vol. I of this manual.

Some information about the Squeak objects used to implement Etoys objects is provided by the Players tool.

Its basic functions are described in the Basic Objects chapter of the first volume of this manual, as are the commands on the menu for each item. 

The command that concerns us here is inspect object. Note that this gives a very different view of the object than the object inspector provided by the object's Halo menu.

In this inspector, the fields have these values.

self  an UnscriptedPlayer (2711) named Polygon
all inst vars dependents:     nil
costume:     a PolygonMorph<Polygon>(171)
costumes:     nil
dependents  nil
costume  a PolygonMorph<Polygon>(171)
costumes  nil
 

Every Etoys object has a variable visual form, called its costume, attached to another object, called its player. Objects such as Sketches that support the graphics category of scripting tiles have a command look like, which in Squeak sends the message wearCostumeOf: anEtoysObject.

When an object contains other embedded objects, each of them appears with a line in the inspector.

What are dependents? What does the costumes line refer to?

Class object:

dependents "Answer a collection of objects that are 'dependent' on the receiver; that is, all objects that should be notified if the receiver changes." ^ self myDependents ifNil: [#()]

31 senders

costumes is an instance value of Player. It is accessed in 12 methods.

Examples needed.

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.