AlignmentMorph and TextMorph
arning at charm.net
Sun Dec 27 18:17:21 UTC 1998
Here is Andrew's example reworked a bit to achieve what I think you are after:
| outer aRow |
outer _ RectangleMorph new extent: 400 at 100.
aRow := AlignmentMorph newRow color: Color lightGreen.
addMorph: (TextMorph new width: 100;
contentsWrapped: 'hellothere'; lock);
addMorphBack: (AlignmentMorph newSpacer: Color blue);
addMorphBack: (TextMorph new width: 100;
contentsWrapped: (12323 printString); rightFlush; lock).
outer addMorph: aRow.
This works in Morphic and MVC, BTW.
I tried your original code (or, rather, Andrew's runnable version) and both fields were editable on my system (2.2). Sending #lock seems to have corrected that.
Sending #rightFlush to the second field gets it lined up as desired.
I set an explicit width for both text fields since the results would be data dependent otherwise.
On Sat, 26 Dec 1998 22:10:45 -0500 "Pennell's" <pennell at tiac.net> wrote:
>I'm trying to create a row on a pane with a left justified name, some space and a right justified
>I created the row as follows:
> aRow := AlignmentMorph newRow color: aColor.
> addMorph: (TextMorph new contents: aName);
> addMorphBack: (AlignmentMorph newSpacer: Color transparent);
> addMorphBack: (TextMorph new contents: aNumber printString).
>Everything displays correctly, but:
> - Why is the first submorph left justified and the last one right justified?
> - Why does the first submorph allow editing and the last one doesn't?
> - How can I prevent editing? I want display only. I tried to use StringMorph's but
> after much experimentation with wrapping in AlignmentMorphs, I trimmed
> the example down to this.
>Thanks - I'm finally trying to learn Morphic so I can teach a 14 year old...
More information about the Squeak-dev