Getting notified when a morph moves
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
Hi, I think you need to subscribe to the hand morph. It provides some possibilities. Of course if you drag morphs only inside it's parent, you can implement dragging by yourself without adding to hand. In this case mouseMove can be received. Cheers, Alex On Wed, Feb 11, 2015 at 9:19 PM, Stephan Eggermont <stephan@stack.nl> wrote:
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
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
I tried something like bellow but it did not produced any output in the transcript. Only "b doAnnounce: MorphChanged" produce an output in the Transcript. Not sure how to get an anonymous morph to announce changes. | b | b := BorderedMorph new color: Color red. b onAnnouncement: MorphChanged do: [ Transcript show: 'Changed' ]. b openInWorld -- Dr. Geo - http://drgeo.eu iStoa - http://istoa.drgeo.eu
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
On 12/02/15 10:20, Hilaire wrote:
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, This works for me. I can attach the listener when the dragging starts, and detach it when it stops. That should do. Stephan
Le 12/02/2015 11:04, Stephan Eggermont a écrit :
This works for me. I can attach the listener when the dragging starts, and detach it when it stops. That should do.
Okay if I understand correctly, the two morphs you want to link with a line are also morphs of yours? So you can mangle into them. I was supposing the two morphs to link could be arbitrary ones, i.e. ones you can't modify. -- Dr. Geo - http://drgeo.eu iStoa - http://istoa.drgeo.eu
participants (3)
-
Aliaksei Syrel -
Hilaire -
Stephan Eggermont