Now I'm really confused :-(
Ned Konz
ned at bike-nomad.com
Tue Jul 16 21:41:43 UTC 2002
On Tuesday 16 July 2002 12:00 pm, david at aminal.com wrote:
> What I don't understand is how to capture the event
> in the pushbutton and then make the *rectangle do
> something, like change color.
> i.e push the button and the light goes on.
> Does a world have a namespace? Can I identify and
> send messages from one morph to another inside a
> world?
Hi David,
It can be confusing at times.
There's a few of ways that one Morph can address another.
You don't say how you're making your Morphs and wiring them to events;
there are at least three ways I can think of:
* Smalltalk programming in a Morph subclass
* Making Morphs and then attaching them to actions and targets via
their menu choices
* Using the EToy/Scripting system and dragging tiles around or editing
test
The answer would be different for all three.
In the case of Smalltalk programming, there are a few ways to do it:
* Something can hold onto references to the other object. Generally
this is either one of the two objects, or something that made one or
both of them.
[Actually, messaging between loose Morphs (i.e. both in the World) is
relatively uncommon outside of the eToy system. By far most of the
Morph to Morph messages are between Morphs and their submorphs or
parents. (or between the Hand and another Morph, but I'm skipping
that for right now).]
There is a built-in relationship between Morphs and their parents, so
you could query the World for a submorphSuchThat: [...something ] .
But I don't recommend this.
* You can refer to Morphs by name, then ask their owner:
morph1 name: 'Morph1'.
...
World morphNamed: 'Morph1'.
If you're using direct manipulation from menus, I'm not sure how to do
this.
If you're using the eToy system, you can refer to another morph in a
script by opening a viewer on the morph you want to refer to, go to
the scripting category, and drag off the phrase that looks like
'MorphName do: script1'
You can then drop that phrase into a script, changing the name of the
script.
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|