Search code examples
smalltalksqueak

How to create an arrow morph in smalltalk80 (squeak) programmatically?


I need to draw an arrow morph from center of one given morph to center of another given morph.

Any help would be appreciated.


Solution

  • Assuming a and b are your morphs:

    arrow := (LineMorph from: a center to: b center color: Color red width: 2) makeForwardArrow.
    arrow openInWorld.
    

    If you want to update the position after the morphs move, do this:

    arrow setVertices: {a center. b center}