[Newbies] Morphic event-handling confusion
max at nbtsc.org
Thu Mar 15 06:31:19 UTC 2007
I'm trying to use Morphic, in Squeak 3.9, to make a very simple "physics
model" I call a HockeyPuck. The idea is that it's a CircleMorph subclass
that one should be able to pick up with the Hand and "throw", and have
it bounce off the World edge (and then, hopefully, other such Pucks).
I've got the "step" animation thing figured out pretty well, and I have
some idea how to compute the motion and bounces and such, but I'm
stumped as to how to properly handle the mouse events. On Eddie
Cottongim's suggestion, at http://wiki.squeak.org/squeak/2477 , I tried
using "self on: #startDrag send: #beginThrow to: self" (in my
initialize method) but that seems a little weird, and doesn't seem to
allow the default dragging behavior to go through. I also tried the
approach of overriding handlesMouseDown and mouseDown, and sending
"super mouseDown" in the latter, but that doesn't seem to work any
better, although it makes a little more sense to me.
There's a two-step sequence of messages I'd like my Puck to receive
while still doing the normal getting-moved-by-the-Hand stuff. The first
is #beginThrow, to be sent either on a mouseDown or (preferably) on a
startDrag event. The second is #endThrow, to be sent on the subsequent
mouseUp. How can I make this happen?
Thank you very much for your time.
More information about the Beginners