[Newbie Q]Morphic /SmallTalk

Stephan Rudlof sr at evolgo.de
Fri Mar 17 02:40:26 UTC 2000


Dear Bert,

thank you very much for your example.
I've just started learning Morphic and such examples are very good as
entry points!

Your example
- solves the problem,
- is minimal,
- contains important concepts;
shortly neat!

Greetings,

Stephan


Bert Freudenberg wrote:
> 
> On Wed, 15 Mar 2000, Karl Ramberg wrote:
> 
> > I'm just starting to learn stuff here and tried to make some
> > simple apps but suddenly found myself in trouble.
> > I'm making two morphs and want one to act as a button and
> > the other to for instance move when I click on the button.
> > I did this in the etoy/ scripting and it was really easy, but
> > now I can't find any way to send the message from class to class.
> 
> To move a morph, send "position: somePoint" to it.
> To make a morph respond to mouse clicks, set an eventhandler.
> 
> For example:
> 
> | a b |
> a _ Morph new color: Color red; openInWorld.
> b _ Morph new color: Color green; openInWorld.
> a on: #mouseDown send: #value to: [b position: b position + (10 at 0)]
> 
> If you click the red morph, the green one will move to the right. It does
> so by sending #value to the given block (stuff inside brackets), which
> causes the code in the block to be executed.
> 
> If you were going to write a method you would set up an eventhandler that
> sends a message to the button morph itself, like
>         self on: #mouseDown send: #moveOtherMorph to: self
> in the moveOtherMorph method you would send position: to the other morph.
> 
> HTH,
> 
>   -Bert-

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list