Morphs differ based on how brought to life?

Dan Shafer dshafer at yahoo.com
Sun Mar 25 04:27:40 UTC 2001


One of the things I _love_ about Squeak is how, every time I think I have
something figured out, it rises up and humbles me.

I'm working my way through the exercises in Mark Guzdial's book. I read it all
the way through to get a grasp of concepts and now I'm doing the exercises.

In Chapter 2, he has a deceptively simple exercise in which he asks only that
we add a Close button to a ScorePlayerMorph.

Figuring out how to add the button took about 5 minutes. Cool.

Figuring out how to make that button actually close the ScorePlayerMorph?
That's a mouse of a different color. I must have spent four or five hours
before I finally figured out that Morphs delete themselves by sending a message
to their owners/parents, rather than handling the action themselves. So I now
have things working so that if in a Transcript I type:

sp _ ScorePlayerMorph new.
sp initialize.
sp openInWorld.

and doIt I get a ScorePlayerMorph instance with a Close button. If I then send
that little doodad a message closePlayer, which I've defined as an instance
method in ScorePlayerMorph, it dutifully goes away.

I declare success. Then I create a new ScorePlayerMorph from the New Morph...
menu, click the Close button. Error. ScorePlayerMorph doesn't understand
closePlayer!? So I go back to my Transcript, create another new
ScorePlayerMorph,, click the Close button....same result. Error.

(BTW, I'm  in Morphic here, at least I'm in a Morphic project.)

Now the closePlayer method is plainly as day right there in the
ScorePlayerMorph, defined as follows:

closePlayer

    super delete.

But why does it run correctly from the Transcript (or at least appear to) but
not from the button?

For completeness, here's the line I've added to the makeControls instance
method of ScorePlayerMorph that adds the Close button:

	r addMorphBack: (bb label: 'Close';			actionSelector: #closePlayer).

It's a copied and changed line from elsewhere in the method so I can't imagine
this wouldn't work in all cases. The other buttons in the ScorePlayerMorph work
just fine.

Whack me with a Stupid Stick but I really to understand what's going on here.

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/





More information about the Squeak-dev mailing list