[MCP] Halo Handling

Ruedi Steinmann ruedisteinmann at gmx.net
Mon Feb 14 20:34:39 UTC 2005


Hi,
I'd like to clean up Morphic somewhat. I started with the eventhandling
( because it's the first thing you have to know about when starting
using Morphic, it's the part I know best). 

First thing: Cleanup of the Halo handling.

Goals:
------
1. If you click (blueButton) on the World, a halo is shown on the world
2. If you click on an already existing halo, the halo is transferred to
one of the halo's target's submorphs. If none is at the event position,
the halo disappears. (Halos are added in front of the World, so they
usually receive the clicks) 
3. If you click on a direct submorph of the World, an existing halo is
transferred to it or a new one is created.
4. Halos stay up as long as you dont't click onto the World.
5. ShiftBueButtonDown opens a Halo on the clicked Morph
6. ShiftBueButtonDown on a Halo transfers halo to owner.

Current Implementation: (Squeak3.9a-6548)
-----------------------------------------
"I love my CallBrowser, helps a lot digging through code"

If a Morph receives an UNHANDLED #blueButtonMouseDown event, it opens a
halo for itself. (Morph>>blueButtonDown:) 

Now, who receives such an event? At first the World registers itself as
receiver. If any of the World's direct submorphs contains the event
point, it will override the receiver with self (because the receiver
isPlayfieldLike at this moment)
(Morph>>handlerForBlueButtonDown:). ( Goals 1 and 3 archieved)
If the receiver isn't the World anymore (not playfieldLike), the
receiver is not overriden except if shift was pressed (Goal 5)

Halos always receive  #blueButtonMouseDown events.
(HaloMorph>>handlerForBlueButtonDown:) They process them (Goal 2 and 6)

PasteUpMorph>>mouseDown: removes halos (Goal 4)

Implementation Proposal
-----------------------
"Before asking Why?, read [MCP] Morphic Event Dispatching."

Now that it all lies before us, it seems quite clear and relatively
simple. But when I digged through the image, it was not. (at least to
me).

On a #blueButtonDown event HandMorph>>handleEvent: (should be renamed to
dispatchEvent:) looks if one of the World's submorphs receives the event
and opens the halo, otherwise open a halo for the World.

"Might contain minor mistakes, it's just to make concept clear"
self owner submorphsDo: [:m¦
 (m containsPoint: evt cursorPoint) ifTrue:[^Halo new popUpFor: m event:
evt.]].
Halo new popUpFor: self owner event:evt.

On a shift #blueButtonDown send a MorphicEvent subclass: #OpenHaloEvent
to the World, which will make the receiver open a Halo on itself.

Let the Halo do the event handling as it does now.

Greets
Ruedi




More information about the Squeak-dev mailing list