[Cuis-dev] TextModelMorph comments

Mark Volkmann r.mark.volkmann at gmail.com
Wed Apr 2 12:11:03 PDT 2025


As a follow up to the Cuis meeting today, here's my initial progress on two
of the comments. I want to get some feedback on this before I add more
comments to the methods of this class. Fire away!

For the TextModelMorph class I have the following:

This is a morph that enables users to view and edit text.

The main features of this class include:
- using either a TextModel or TextProvider to hold the text being edited
- styling and text wrapping (provided by InnerTextMorph)
- scrolling with scrollbars (provided by superclass PluggableScrollPane)

There are two approaches for creating instances. One approach is to hold
the text value in a TextModel object. The class methods withModel: and
withText: support this. The other approach is to hold the text value in a
TextProvider. The class methods that begin with textProvider: support this.
For examples, see the method comments in those class methods.

The default background color is white. A border is only displayed when it
has focus. One way to make its bounds apparent when it doesn't have focus
is to set the background color of the parent component. Another way is to
set the background color of this morph.

By default, words that would extend past the right side wrap to the next
line. To prevent wrapping, send an instance #wrapFlag: with an argument of
false.

The default size is 200 by 100, set in the initialize method of the
superclass PluggableMorph. Depending on the font, the default size displays
around four lines of wrapping text with around 17 characters per line. To
change the size, send an instance #morphExtent: with a Point argument that
specifies a width and height. The size should include space for scroll bars
if they may be needed. Setting the height to zero causes it to actually be
set to the height required for a single line in the current font.

Related classes include TextModel, TextProvider, PluggableScrollPane, and
InnerTextMorph.

For the class method testProvider:textGetter:textSetter: I have this:

 Answer a new instance that gets the text from aTextProvider.

aTextProvider must have corresponding getter and setter methods
that manage the text to be edited.
For example, we can use an instance of the Exception class
which has the methods messageText and messageText:.

Select and evaluate the code below.
In the Inspector that appears, select the messageText instance variable.
In the TextModelMorph that appears, change the text
and note how it updates in the Inspector.

| exception morph |
exception := Exception new.
exception messageText: 'initial'.
exception inspect.
morph := TextModelMorph textProvider: exception textGetter: #messageText
textSetter: #messageText:.
morph acceptOnAny: true.
morph openInWorld.

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250402/886a4542/attachment.htm>


More information about the Cuis-dev mailing list