It can't get the Pen to work properly in a Morph.
I arrived at the snippet below but I don't understand how to update the view of the Morph after I moved the pen. I tried to send "changed" in various (sm, pen, (sm owner)) object but it does not solve it.
In the snippet below the line gets drawn if I resize the window. Or, also, if i put "openInWindow" as last line.
sm := SketchMorph new.
sm clearExtent: 600@600 fillColor: (Color yellow) darker darker.
sm position: 100@100.
sm openInWindow.
pen := sm penOnMyForm.
pen defaultNib: 4; color: (Color red).
pen up.
pen goto: 10@10.
pen down.
pen goto: 100@100.
The message you should send to the
SketchMorph, instead of#layoutChanged, iswhich is -pun intended- quite intention revealing; isn't it?
How did I find it
Using the hint provided by Nicola, I debugged
sm layoutChangedtrying to understand why it showed the line. I had triedsm changedbefore with no luck, so I knew that the clue had to be ingenerateRotatedForm. And since this method redefines the ivarrotatedForm, I looked for all methods that changed it, as I suspected that the problem was in some cache not being invalidated bychanged. Quickly enough, the selectorrevealPenStrokesemerged victorious from the rather short list of methods modifyingrotatedForm.