Hello Stephan, I guess HandleListenEvent: was implemented for such a use. Cheers Alain
On 18 May 2015, at 14:36, Stephan Eggermont <stephan@stack.nl> wrote:
Thanks Alain.
On 15-05-15 23:48, Alain Plantec via Pharo-users wrote: - HandleListenEvent: is for particular purpose, used rarely.
I wonder about the way I'm using it. When drawing a connector between two shape morphs, I do the following:
- I have a context menu on the shape, calling #connect
MDShapeconnect |connector| connector := MDTempConnector from: self to: ActiveHand isBezier: false. connector openInWorld.
When creating the MDTempConnector, I start listening to the hand's events
MDTempConnector>>to: aHand to := aHand. ActiveHand addEventListener: self.
MDTempConnector>>handleListenEvent: anEvent anEvent isMouse ifFalse: [ ^super handleListenEvent: anEvent]. anEvent isMouseUp ifTrue: [ self stopListening: anEvent]. anEvent isMouseMove ifTrue: [ self moved. self highlightShapeAt: anEvent ]
And I stop listening on mouse up, possibly replacing the temporary one by a permanent one.
MDTempConnector>>stopListening: anEvent ActiveHand removeEventListener: self. (self shapeAtPosition: anEvent) ifNotNil: [ :shape | from owner addMorphBack: (MDConnector from: from to: shape isBezier: smoothCurve) ]. over ifNotNil: [ over unhighlight ]. self delete
Stephan