My first morph

Bert Freudenberg bert at
Tue Nov 8 17:20:59 UTC 2005

Am 08.11.2005 um 15:33 schrieb Bob.Cowdery at

>  Bert Freudenberg wrote:
> > Look into class PianoKeyboardMorph, specifically #buildKeyboard. It
> > builds each key as a separate Morph and uses #on:send:to:withValue:
> > to wire events.
> As far as I can make out this is a way to delegate sensor events to  
> some other object. They fire only if the object receiving the event  
> does not handle it. I tried it with mouseDown which my digit morph  
> does not use and it fires, with mouseOver which it does use it's  
> handled so doesn't fire.

That is correct - if you choose to override the default behavior in  
your morph you're on your own (unless you call super's version of the  
mouse over handler, which would allow the on:send:to: mechanism to  
continue to work).

> I could potentially use this to handle handleKeystroke so delegate  
> the parent to managing the mouse wheel. However, that gives me an  
> error when I try it. What I really want to do is something like  
> raiseEvent from my code and then 'on: myEvent send: myHandler to:  
> self'. Is there no equivalent to raiseEvent in Morphic?

See the categories named "event-..." in class Object. There are usage  
examples in classes EventTest and EventManagerTest. Basically, use  
#when:send:to: to register a handler and #triggerEvent: to trigger  
the event.

A special problem is that #when:send:to: has nothing to do with  
#on:send:to: (which is older), which again has nothing to do with the  
even older #changed/#update mechanism. However, all of these are used  
in places, and there are even more obscure notification mechanisms in  
the image. Also, all of them are synchronous (a weakness only solved  
in Tweak AFAIK).

- Bert -

More information about the Squeak-dev mailing list