Mantis - Squeak
Viewing Issue Advanced Details
1431 Morphic minor always 07-08-05 00:47 07-08-05 00:48
masm  
 
normal  
new 3.8  
open  
none    
none  
0001431: [BUG] Embedded TextMorph autoFill with empty text problem!
"John R. Pierce" <john@pierce.name>:

Hi all,

I uncovered a problem with TextMorph's that are embedded in Morphs with the
autofill property turned on. It seems to exhibit itself in both 3.6 and 3.7.

Basically, if the underlying text of the TextMorph gets set to an empty string,
then when the user starts typing in an empty TextMorph, the new text will not
get shown until a layoutChanged is called (and subsequent repaint cycle).

It appears TextMorph>>updateFromParagraph does call layoutChanged, but that call
doesn't seem to help. Attached is a little bit of code to see the problem:

  morph := Morph new.
  morph extent: 100 @ 20.
  text := TextMorph new.
  morph addMorph: text.
  text
    fillingOnOff;
    color: Color white;
    contents: ''.
  morph openInWorld.

  "Now go try to type in the TextMorph and see what I mean"

  "Then run the following code to get the TextMorph to re-display the new text"
  text layoutChanged.
  morph invalidRect: morph bounds. "This is only necessary on 3.6"

If you use a larger embedding morph then the one I had in my sample, you will
actually see the new text showing up on the second line of the morph. This may
be a clue as to what is going on.

Lastly, I noticed this can be fixed by hacking updateFromParagraph and adding an
"ActiveWorld doOneCycle" call right after the call to "self fit" (near the top
of the method).

Regards,

John
Problem still present in in 3.8-6665

Notes
(0001718)
masm   
07-08-05 00:48   
Yeah, when I did the NCDisplayTextMorph for Connectors I ended up doing
something roughly like this (but only when autoFit and no wrap)
(lifted from the StringMorphEditor):

updateFromParagraph
    | priorEditor |
    super updateFromParagraph.
    priorEditor := editor. "Save editor state"
    self releaseParagraph. "Release paragraph so it will grow with selection."
    self paragraph. "Re-instantiate to set new bounds"
    priorEditor
        ifNotNil: [self installEditorToReplace: priorEditor].
    self editor

--
Ned Konz
http://bike-nomad.com [^]
GPG key ID: BEEA7EFE