[Q][Drag&Drop] Event handling, PolygonMorph, line drawing questions

Stephan Rudlof sr at evolgo.de
Mon Apr 24 02:47:23 UTC 2000


Dear Squeakers,

I'm trying to use PolygonMorph (or a similar subclass) to visualize
drag&drop operations.
I want to have a line from the drag start point following the hand while
dragging a Morph to the drop position.

My problem is the following:
The EllipseMorphs used as handles need mouse events to rescale the
PolygonMorph.
I have seen that, if I'm taking some Morph by a drag&drop operation, it
doesn't get any events anymore.

So how is it possible to drag a Morph *and* to give it events further?

Or is there a better possibility?

First I have searched for a possibility to draw simply dashed lines (?).

Then I have tried to draw such lines directly on the canvas in the
#drawOn: method of the dragged morph, but update doesn't work then (is
there an invalidate method which can be called *inside* a draw method?).
-> drawing lines directly seems to be much faster as using Morphs (I'm
not wondering about...)!

Then I have searched for morphs, and found this PolygonMorph one.
-> seems to be a little bit overhead for my goal.

Last I have made such horrible code as

TransferMorph>>
aboutToBeGrabbedBy: aHand 
	| pm handle |
	self position: aHand position - self firstSubmorph height.
	pm _ PolygonMorph
				vertices: (Array with: aHand position with: aHand position)
				color: Color red
				borderWidth: 1
				borderColor: Color red.
	pm addHandles.
	handle _ pm handles at: 1.
	pm openInWorld.
	self addMorphBack: handle.
	aHand mouseDownMorph: self.
	aHand eventTransform: MorphicTransform identity.
	self
		on: #mouseStillDown
		send: #dragVertex:fromHandle:vertIndex:
		to: pm
		withValue: 1

This works optically; it gives the desired *visual* effect after
starting dragging. But directly setting mouseDownMorph with changing the
eventTransform seems to be ugly for me.
And the main problem now is:
Drag&drop doesn't work, because now the handles (EllipseMorphs) of the
PolygonMorph eat up the events necessary for drag&drop!


I'm thankful for any hints (or links to TFM's).

Greetings,

Stephan

P.S.: It's easy to get lost in HandMorph/EventHandling code...
-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list