[Q][Design] Subclassing and EventHandlers

Martin Drautzburg martin.drautzburg at web.de
Sat Apr 20 10:27:08 UTC 2002

I want a Rectangle with a Button inside. The twosome should be
draggable and accept drops. I did that with by subclassing
RectangleMorph and adding a SimpleButtonMorph as submorph.

Now the bad thing is, I cannot drag this when I grab the button. The
button hat its own ideas about mouse responses. I also cannot plug in
new event handling because the button unfortunately does not use an
event handler. I would have to subclass the Button and override the
event handling methods. This give me one extra Class.

I could also construct the Button myself from RectangleMorph, String
Morph and the like. This way I would not need an extra class. But I
assume I would end up writing more lines of code.

I could also subclass SimpleButtonMorph and put a Rectangle around
it. But this is rather odd: a submorph *around* its owner.

Are there any better options ?

More information about the Squeak-dev mailing list