[Etoys] EllipseMorph and sibling instance

Scott Wallace scott.wallace at squeakland.org
Sun Apr 13 17:17:12 EDT 2008


On Apr 13, 2008, at 8:20 AM, polishookm wrote:

> To answer my own question, I think what I'm observing is noted  
> below. If
> someone could comment that what I'm describing is how things work,  
> that
> would be great.

Hi, Mark,

Basically, your observations are correct, but please see the comments  
after #9 and #10.


> 1. I make an EllipseMorph
> 2. I open a viewer on the EllipseMorph and make a script. The script
> belongs to a Player and the Player wears the EllipseMorph
> 3. I bring up a halo on the EllipseMorph and click on the green
> Duplicate icon.
> 4. Now I have 2 Players, each of which wears an EllipseMorph
> 5. Opening an AllScriptsTool provides for start/stop/stop control over
> both Players
>
> 6. I make a RectangleMorph
> 7. I open a viewer on the RectangleMorph and make a script. The script
> belongs to a Player and the Player wears the EllipseMorph
> 8. I bring up a halo on the RectangleMorph and shift-click on the  
> green
> Duplicate icon.
> 9. Now I have 1 Player that's wearing (controlling) 2 RectangleMorphs.

Almost...  What you now have are two *sibling players*, each of which  
is a "Player" in its own right.  Each players wears its own separate  
RectangleMorph as its costume.  The siblings are related in that they  
have (and will forever have) the same "shape" (i.e. each has the same  
list of "variables") and in that they share (and will forever share)  
the same scripts.  If you add a variable to one of them, the same  
variable will be added to the other.  If you add a script to one of  
them, the same script will apply to the other one.

But although siblings share a script, each sibling has its own private  
"status" for that script, i.e. remembers separately whether the script  
*as used by this instance* is "normal", "paused,", or "ticking", or  
set to trigger on mouse-up, etc.; and what the tick-rate is.

When using siblings, what's really happening underneath is that there  
is a custom Player "Class" is created to bear the shared code, and the  
siblings are individual "Instances" of that class.  "Class" and  
"Instance" are among the most fundamental concepts of object-oriented  
programming, but we don't much use the terms "class" and "instance" in  
the etoys UI, nor in any documentation I'm aware of.  (A notorious  
exception is the "all instances" checkbox in the all-scripts tool.)   
We refer to "siblings" but don't have a formal term for the "class".   
Hmm...  maybe the checkbox should read "all siblings" rather than "all  
instances"...


> 10. Opening an AllScriptsTool provides for start/stop/stop control  
> over
> the Player that wears the 2 RectangleMorphs

If the "all instances" box is not checked, you'll see the scripts for  
only one player of each sibling group.  This will give you "control"  
over the scripts of only one of the players.  If you want to be able  
to "control" scripts for both of the siblings, make sure the "all  
instances" checkbox is checked.


> I'm noticing that if AllScripts tool is on screen while  
> EllipseMorphs or
> RectangleMorphs are being duplicated, it won't then immediately pick  
> up
> on the fact that new Players exist. A new Player has to be run once  
> and
> then the AllScriptsTool knows it's there.

Unless the "all instances" checkbox is checked, creation of new  
siblings will typically not result in any noticeable change in the all- 
scripts tool, since all the scripts of the new sibling will already be  
represented by another instance in the tool.  Perhaps that's what  
you're seeing.

Also, if the "tickers only" box is checked, only scripts whose status  
is "ticking" or "paused' are shown in the all-scripts tool.  This can  
be another reason why the all-scripts tool may seem not to be "picking  
up" on a change.

AFAIK, it's fine to have an all-scripts tool open as you create,  
delete, rename, and otherwise manipulate objects and scripts; I'm not  
aware of situations where it "misses" anything, but if you can  
describe a sequence of steps leading to such a situation, it would be  
helpful.

----------

I hope this helps some.  We are still woefully short of documentation  
in this area and much about "siblings" is not particularly obvious.   
(But I presume that people interested in "siblings" will have read the  
contents of the "All Scripts" help-flap that is obtained by clicking  
on the ? in the all-scripts tool.)

A couple of nice, simple tutorial projects in Squeak about these  
matters would be so very welcome...

Cheers,

-- Scott


More information about the Etoys mailing list