Another stupid Morphic Question
Tom Phoenix
rootbeer at redcat.com
Mon Apr 30 17:59:05 UTC 2007
On 4/30/07, Andrew P. Black <black at cs.pdx.edu> wrote:
> I have a RectangleMorph (subclass). Embedded in it are a number of
> CircleMorph (again, actually a subclass) connected by NCAAConnectorMorphs.
>
> I want to be able to move the circles by dragging them with the red button.
> This is exactly the default behavior when they are in the World — but when
> they are in the RectagleMorph, a mouse click picks up the whole rectangle.
> I have tried making handleMouseDown: answer false in the RectangleMorph, and
> to answer true in the circles — this doesn't help.
>
> Conversely, I _don't_ want to be able to pick up the Rectangle with a single
> red click. But I can, and I can't turn this off, even though
> handlesMouseDown: and handlesMouseStillDown: answer false.
I'm not an expert, so what follows is from my own experience trying to
do something similar.
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. I think you want the responsive object (the circle) to
answer true to handlesMouseDown:, and you want a handleMouseDown:
method that marks the click as handled if you don't want somebody else
to handle it. My object (which responds differently than yours) used
this handler:
handleMouseDown: evt
evt controlKeyPressed ifTrue: [^super handleMouseDown: evt].
evt redButtonPressed ifTrue: [ "pick it up"
evt wasHandled: true.
self removeHalo.
^evt hand grabMorph: self from: owner].
evt yellowButtonPressed ifTrue: [ "control menu"
evt wasHandled: true.
self removeHalo.
^self invokeMetaMenu: evt ].
^super handleMouseDown: evt
Good luck with it!
--Tom Phoenix
More information about the Squeak-dev
mailing list
|