AlignmentMorph and TextMorph
Andrew C. Greenberg
werdna at gate.net
Sun Dec 27 06:02:55 UTC 1998
> I'm trying to create a row on a pane with a left justified name, some
> space and a right justified
> number.
>
> I created the row as follows:
>
> aRow := AlignmentMorph newRow color: aColor.
> aRow
> 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?
It isn't. Neither is "justified," as I noted in my previous message. What
you saw was three "fields," fully filled without padding, and all abutted
one to another to make up the aggregate morph. Text is always
simultaneously left, center and right justified in a field that is exactly
the width of the text. Running your code and inspecting the results with
an inspector confirms this:
|aWorld |
aWorld _ WorldMorph new initialize.
aRow := AlignmentMorph newRow color: aColor.
aRow
addMorph: (TextMorph new contents: 'hellothere');
addMorphBack: (AlignmentMorph newSpacer: Color transparent);
addMorphBack: (TextMorph new contents: (12323 printString)).
aWorld addMorph: aRow.
aWorld openWithTitle: 'test'.
bounds: 54 at 46 corner: 112 at 62 112 at 46 corner: 114 at 82 114 at 46
corner: 126 at 62
owner: an AlignmentMorph(1871) an AlignmentMorph(1871) an
AlignmentMorph(1871)
submorphs: () () ()
fullBounds: 54 at 46 corner: 112 at 62 112 at 46 corner: 114 at 82 114 at 46
corner: 126 at 62
color: (Color r: 0.0 g: 0.0 b: 0.0) (Color r:
0.0 g: 0.0 b: 0.0)
(Color transparent)
extension: nil nil nil
textStyle: a TextStyle NewYork10 a TextStyle
NewYork10
text: Text for 'hellothere' Text for '23'
Both TextStyles had alignment set to 0, "left justification".
The resulting morph looked like this:
+---------------------+
|+-----------++--++--+|
||hello there|| ||23||
|+-----------+| |+--+|
| | | |
| +--+ |
+---------------------+
> - Why does the first submorph allow editing and the last one doesn't?
I have no idea. I confirm that the second field is not editable, and defer
to those who actually know how this stuff works to explain why this should
be so.
More information about the Squeak-dev
mailing list
|