[Cuis-dev] Morphic Hello World failure
short.toy8168 at lrz.me
short.toy8168 at lrz.me
Mon Feb 9 06:27:26 PST 2026
I am learning Morphic and tried the "hello world" [1].
The LabelMorph "crashes" when pressing the greet button:
| view input label button row |
view := LayoutMorph newColumn.
input := TextModelMorph withText: '' .
input hideScrollBarsIndefinitely; morphExtent: 200 @ 0; wrapFlag: false.
label := LabelMorph contents: ''.
label color: Color red.
button := PluggableButtonMorph model: [label contents: 'Hello, ', input text, '!'] action: #value.
button label: 'Greet' .
row := LayoutMorph newRow.
row addMorph: (LabelMorph contents: 'Name:'); addMorph: input; addMorph: button .
view addMorph: row; addMorph: label.
w := SystemWindow new setLabel: 'Hello World!'.
w addMorph: view; openInWorld; morphExtent: 0 at 0.
The state of the 'color' instance variable is corrupted
(in LabelMorph>>contents: setter), it becomes nil!
Which is not a color, right?
My problem is in deciding where the root cause is.
I have hypotheses like:
1. LabelMorph>>contents: assumes colors exists in new content and should not.
2. TextModelMorph>>text doesn't provide the returned text with a color attribute
3. nil is supposed to be a color and the calling code is just out of date or wrong.
I found it hard to decide where the defect (ie. the "wrong line of code") is [2].
How do we fix the hello world?
Lorenz
[1] https://drcuis.github.io/DesignGUI/Quick-Start.html
[2] I suspect the LabelMorph>>contents: method should be more careful.
color := (newContents colorAt: 1) ifNil: [ color ].
More information about the Cuis-dev
mailing list