Search code examples
smalltalksqueak

Create LineMorph From 100@100 to mouse location in smalltalk


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 ?


Solution

  • 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.