porting 2.7 morph dragging to 3.1

Tim Rowledge tim at sumeru.stanford.edu
Mon Jul 9 03:26:39 UTC 2001


Thanks for the explanation Jim!

I think my needs are way on the simple end of the dragNdrop continuum.
I have a bunch o'morphs in a tree arrangement and need to be able to
drag individual morphs (or actually sometimes subtrees) around within
their world, updating the position of line endpoints so that
everything stays linked together. The 2.7 code original traps mouseDown:
and uses waitForClicksOrDrag:, and seems to rely on getting a stream of
#drag: events.
I don't need to drag ThingyMorphs outside their little world, nor drop
them on top of each other, nor anything too clever.

!ThingyMorph methodsFor: 'event handling' !
drag: evt
	| p oldPosition |
	p _ evt cursorPoint.
	oldPosition _ self position.
	self position: p - evt hand targetOffset.
	evt shiftPressed ifTrue: [self allChildMorphsDo: [:m | m position: m position + (self position - oldPosition)]]! !


!ThingyMorph methodsFor: 'event handling' !
mouseDown: evt 
	Sensor yellowButtonPressed ifTrue: [self createMenu]
ifFalse:[
	Sensor redButtonPressed ifTrue: [evt hand waitForClicksOrDrag: self event: evt]]! !

Now, I did actually try a quick evt hand grab: self (or something like
that) and it does indeed allow me to grab the morph, but I didn't spot
any way to make sure the attached lines got updated as well.

I should add that I'm not the orginal author and am completely
inexperienced in the ways of Morphic. I just spend too much time
fiddling with the VM!

tim 

-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Useful random insult:- A day late and a dollar short.





More information about the Squeak-dev mailing list