Hi, Here is an implementation example. >From a workspace, do:
| morphA morphB follower | morphA := Morph new position: 10@10. morphB := Morph new position: 100@100. follower := FollowerLineMoprh from: morphA to: morphB. morphA openInWorld. morphB openInWorld. follower openInWorld. Frankly I don't like the idea to subscribe to the HandMorph, because at each mouse move event, you have to check for the morph A and B if they move. It is a waste of CPU cycles. Ideally you will want receive event from morph A and B whenever they changed. I am surious to know if it is possible. Thanks Hilaire Le 11/02/2015 21:19, Stephan Eggermont a écrit : > I'm trying to keep a line morph connected between two morphs > while moving one of them. > When I add the morph to the hand and start dragging the morph > no longer receives mouseMove:. I can think of several ways to get > position updates. Is there a best/easy way? > > Stephan > > -- Dr. Geo - http://drgeo.eu iStoa - http://istoa.drgeo.eu
'From Pharo3.0 of 18 March 2013 [Latest update: #30862] on 12 February 2015 at 10:13:28.243708 am'! LineMorph subclass: #FollowerLineMoprh instanceVariableNames: 'morphA morphB' classVariableNames: '' poolDictionaries: '' category: '_UnpackagedPackage'! !FollowerLineMoprh commentStamp: 'HilaireFernandes 2/12/2015 10:13' prior: 0! I draw a connected line to two morphs.! !FollowerLineMoprh methodsFor: 'initialization' stamp: 'HilaireFernandes 2/12/2015 09:56'! initialize super initialize. Transcript show: 'initialized';cr.! ! !FollowerLineMoprh methodsFor: 'accessing' stamp: 'HilaireFernandes 2/12/2015 09:51'! morphB: aMorph morphB := aMorph! ! !FollowerLineMoprh methodsFor: 'accessing' stamp: 'HilaireFernandes 2/12/2015 09:51'! morphA: aMorph morphA := aMorph! ! !FollowerLineMoprh methodsFor: 'submorphs-add/remove' stamp: 'HilaireFernandes 2/12/2015 10:07'! delete super delete. ActiveHand removeMouseListener: self! ! !FollowerLineMoprh methodsFor: 'events-processing' stamp: 'HilaireFernandes 2/12/2015 10:11'! handleListenEvent: anEvent anEvent isMouseMove ifFalse: [ ^ self ]. Transcript show: 'Mouse mouve event'; cr. morphA center = self firstVertex ifFalse: [ self verticesAt: 1 put: morphA center ]. morphB center = self lastVertex ifFalse: [ self verticesAt: 2 put: morphB center ] ! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! FollowerLineMoprh class instanceVariableNames: ''! !FollowerLineMoprh class methodsFor: 'instance creation' stamp: 'HilaireFernandes 2/12/2015 10:05'! from: morphA to: morphB | line | line := super from: morphA center to: morphB center color: Color red width: 2. line morphA: morphA; morphB: morphB. ActiveHand addMouseListener: line. ^ line! !