[Q][Design] Subclassing and EventHandlers

Bob Arning arning at charm.net
Sat Apr 20 10:48:35 UTC 2002


On 20 Apr 2002 12:27:08 +0200 Martin Drautzburg <martin.drautzburg at web.de> wrote:
>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. 

You have mentioned this several times and I have wondered each time why it was that you used a SimpleButtonMorph if you didn't want its mouse-handling characteristics. What is it that you *are* using from SimpleButtonMorph that you couldn't get from a RectangleMorph?

>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.

Ahh... is this *it*? It's much better not to assume. ;-) Let's see...

	RectangleMorph new
		addMorph: ((m _ StringMorph contents: 'hello, world') 
								lock; setToAdhereToEdge: #center);
		extent: m extent + (8 at 8);
		openInWorld

Does that work for you?

Cheers,
Bob




More information about the Squeak-dev mailing list