Editing an UpdatingStringMorph

Dan Ingalls Dan.Ingalls at disney.com
Sat May 19 04:52:17 UTC 2001


>On the other hand, the TextMorphs are not working in the TableMorph.  After 
>I type one character the focus shifts to the start of the textMorph.  So, 
>for example, if you just type, everything appears backwards.

A number of problems have crept into TextMorph over the years since it was first written.  Rather than fix them all right now, I'll at least explain this one enough so that some other brave soul should be able to fix it.

The state required to type text into a TextMorph is kept in a TextMorphEditor.  It inherits all the keyboard commands form the old MVC ParagraphEditor, and keeps track of the selection.  It is thrown away when the text is not being edited.  [Even the Paragraph (captures composition into lines) is thrown away when the text is not being displayed, but that's another story].  The editor gets thrown away by #releaseEditor, when focus leaves, and it gets re-created on demand in #installEditor.  Doing a release/install cycle is almost transparent, except that you lose the selection.  If this happens during type-in, you guessed it, the typing gets reversed.

There are two solutions when this happens.  Either it's a situation where you have control of both the release and the install, or not.  If it is, then you can save the prior editor, and then use "installEditorToReplace: priorEditor" for the install.  If it's not, then either you have to prevent the release (say, avoid losing control, or focus), or you have to save the selection state and restore it as is done in installEditorToReplace:.

There.  No fish today, but now you have a fishing pole.

Hope this helps

	- Dan






More information about the Squeak-dev mailing list