Another stupid Morphic Question

Andrew P. Black black at cs.pdx.edu
Tue May 1 07:33:53 UTC 2007


Thanks for your help Tom.  I am making progress, but I'm not there yet.

Brad: I'm not talking about the Halo operations, which work fine.   
What I want to do is make the circles behave on redButtonPressed just  
as if I were using the "move" halo button.  This is the default  
behavior when the circle is in the World.

The key phrase was: "If handlesMouseDown: answers false, that means  
that your object
doesn't handle mouse down events, _so somebody else has to decide how
to handle them_".  So by setting handlesMouseDown to false, I was  
making the morph react to mouse down, which is a bit counter- 
intuitive.  The way to make it _not_ respond to mouse down is to have  
handlesMouseDown: answer true, but to have a mouseDown: evt method  
that does nothing.  Or maybe it should do
			evt wasHandled: true.

OK, so the converse is true.  if I want my circles to handle Mouse  
Down, then they need to answer true to handlesMouseDown: (that's  
easy), and then there needs to be a mouseDown: evt method that does  
the "right thing".  However, the right thing is very complicated!  I  
tried the following, based on Tom's code:


mouseDown: evt
	evt redButtonPressed
		ifTrue: ["pick it up"
			evt wasHandled: true.
			self removeHalo.
			^ evt hand grabMorph: self from: owner]

but this glues the morph to the hand, and I have to click again  
(rather than releasing the red button) to drop it.  Once dropped, the  
circle is no longer embedded in its (former) owner.

I could probably find all of the bits of code that I need, to handle  
mouse move and so on, taking care of the offset between mouse click  
event and the origin of the Morph that I'm moving — most of the code  
must be in HaloMorph.  But this was the Default Behavior of the  
circle before I embedded it in the rectangle — surely there must be  
an easier way to get that default behavior back, other than  
duplicating the code from whereever it is hidden!

	Andrew

Andrew P. Black
Department of Computer Science
Portland State University
+1 503 725 2411



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070501/f190618c/attachment.htm


More information about the Squeak-dev mailing list