--- On Tue, 10/19/10, Clemens Eisserer <[email protected]> wrote:

> From: Clemens Eisserer <[email protected]>
> Subject: [Newbies] Why mouseDown only called for the first morph?
> To: [email protected]
> Date: Tuesday, October 19, 2010, 10:04 AM
> Hi,
> 
> I am new to Squeak and I try to write a tic-tac-toe like
> game.
> 
> I have a BorderedMorpth as board to which I add some
> EllipseMorphs as childs:
> 
> > for: 1 to : ...... [
> > child := OwnEllipseMoph new.
> > bordered addMoprh: child.
> > child bounds: x...@ypos corner:
> (xPos+fieldSize-5)@(yPos+fieldSize-5). ]
> 
> The result looks like the following image: http://93.83.133.214/morph.png
> All the EllipseMorphs are identical and change their color
> at mouseDown:
> 
> > handlesMouseDown: evt
> > ^ true
> 
> > mouseDown: evt
> >    self color: Color green.
> >    ^true
> 
> The problem is that I only receive mouseDown on the first
> EllipseMorph I add.
> When I click on the other EllipseMorphs nothing happens.


> 
> Any idea what the problem could be? Could it be the
> bound-setting
> confuses Morph's event handling?

Morphs have several ways of handling events. The way you picked I had problems 
with. Sending an myMorph on: #mousedown send: #message seems to work best for 
me.

If you want to debug what you are doing bringing up an inspector on a morph or 
exploring the parent morph might prove useful. #haltOnce might prove helpful 
too.

Offhand I would guess that the first one works because its topLeft corresponds 
to the top left of the parent morph and the other ones don't. 
Events are dispatched by translating them in to local coordinates for some 
value of local. When something doesn't work most programmers try a different 
way rather than track down the problem. Event debugging is both difficult and 
patches are of course prone to break things elsewhere. There is some very 
brittle code here.

For examples of things that work look at how polygons get their handles to 
handle events.

hth, 

Yours in curiosity and service, --Jerome Peace





_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to