Create LineMorph From 100@100 to mouse location in smalltalk

397 views Asked by At

I'm stuck with a simple thing i cant understand please help me out I'm really stuck

i need to create a LineMorph that will change dynamically start from point 100@100 To mouse location how can i achieve it ?

1

There are 1 answers

2
codefrau On BEST ANSWER

You should create your own morph subclass to handle mouse events. Or you can use a ready-made HandleMorph:

| line handle |
line := (LineMorph from: 100@100 to: 100@100 color: Color red width: 2) openInWorld.
handle := HandleMorph new forEachPointDo:
    [:newPoint | line setVertices: {100@100. newPoint}].
self currentHand attachMorph: handle.