links to this page:    AlignmentMorph 100 calculi 500 calculi SameGame Swiki Page List AlignmentMorph examples PluggableButtonMorph example aBookMorph makePageControlsFrom: controlSpec aBookPageSorterMorph addControls
AlignmentMorph newRow
Last updated at 12:05 am UTC on 10 January 2022
The method #newRow is a convenience method in AlignmentMorph to get layout behaviour for submorphs.

AlignmentMorph newRow
addMorph: (EllipseMorph new extent: 40@40; color: Color red);
addMorph: (EllipseMorph new extent: 50@50; color: Color yellow);
addMorph: (EllipseMorph new extent: 60@60; color: Color green);
addMorph: (EllipseMorph new extent: 70@70; color: Color blue);
position: 20@20;
openInWorld

Note that the AlignmentMorph object is actually the small light green dot on the top left side. This is because it was not defined how extent should behave.

In Pharo

Try also newColumn instead of newRow.
Try using addMorphBack: instead of addMorph.

Useful for example to build simple tools with SimpleButtonMorphs or PluggableButtonMorphs.

Using a TableLayout policy (Squeak 5.3)

Morph new
color: Color white darker;
layoutPolicy: TableLayout new;
layoutInset: 5;
cellInset: 1;
listDirection: #leftToRight;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;

addMorph: (EllipseMorph new extent: 40@40; color: Color red);
addMorph: (EllipseMorph new extent: 50@50; color: Color yellow);
addMorph: (EllipseMorph new extent: 60@60; color: Color green);
addMorph: (EllipseMorph new extent: 70@70; color: Color blue);
position: 20@20;
openInWorld
The Morph object which contains the submorphs is no longer a dot but the light gray area. This is because hResizing: and vResizing: have been set to #shrinkWrap.

### inARow:

What is the difference between

| a |
a:= AlignmentMorph newRow.
10 timesRepeat: [a addMorph: (EllipseMorph new color: Color random)].
a openInWorld

and
| a coll |
coll := OrderedCollection new.
10 timesRepeat: [coll add: (EllipseMorph new color: Color random; extent: 40@40)].
a:= AlignmentMorph inARow: coll.
a openInWorld

See also Example - aMorph addMorph: anotherMorph (no layout and TableLayout) for layout of submorphs of a RectangleMorph.