[Cuis] StringMorph and lf

Juan Vuletich juan at jvuletich.org
Wed Jan 28 07:39:15 CST 2015


Hi Dan,

(below)

On 1/26/2015 12:19 AM, Dan wrote:
> Howdy,
>
> On 24 Jan 2015 at 20:44, dnorton at mindspring.com wrote:
>
>> Hi Juan,
>>
>> By subclassing SystemWindow, I defined a simple window with 3 panes,
>> using LayoutMorph
>> newRow for each. Two of these have StringMorph as a submorph.
>> Strings in this app, which
>> are for display only, contain Character lf in several places are
>> sent using
>> StringMorph>contents:. They are drawn with every lf removed. Can
>> StringMorph be
>> commanded to honor the lf? Is there something better that should be
>> used instead of
>> StringMorph?
>>
> Using StringMorph in this way may be too simplistic.
> Instead use TextModelMorph with a model which is a subclass of TextModel. At least this
> can draw with the lf characters in place. It's more complex and it allows editing of the string
> by default but maybe that can be suppressed?
>
>   - Dan Norton
>

You don't really need a new class. This works:

         model := TextModel new contents: 'Hi folks, \this is a 
multiline text, \see?' withNewLines .
         doWrap := true.
         m := TextModelMorph withModel: model.
         m wrapFlag: doWrap.
         m hideScrollBarsIndefinitely.
         m lock.
         m openInWorld

Locking the morph is not the ideal thing to do, as you can't grab it 
with the halo anymore. You can add a readOnly capability to 
TextModelMorph, that would be a welcome addition. Also, maybe some 
convenience method with code like my snippet above could be useful.

Cheers,
Juan Vuletich





More information about the Cuis mailing list