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
, is
sm revealPenStrokes
which is -pun intended- quite intention revealing; isn't it?
Using the hint provided by Nicola, I debugged sm layoutChanged
trying to understand why it showed the line. I had tried sm changed
before with no luck, so I knew that the clue had to be in generateRotatedForm
. And since this method redefines the ivar rotatedForm
, I looked for all methods that changed it, as I suspected that the problem was in some cache not being invalidated by changed
. Quickly enough, the selector revealPenStrokes
emerged victorious from the rather short list of methods modifying rotatedForm
.