Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
aMorph submorphsDo: aBlock
Last updated at 5:28 pm UTC on 23 February 2017
When using #addMorph: new instances of the class Morph are added in front of the submorphs list.

Thus the red morph though added first appears last when executing

 aMorph submorphsDo: aBlock

A number is attached to each submorph when the block is executed.

| w p1 p2 p3 p4 msize number offset |

w := PasteUpMorph new extent: 600@480; position: 10@30.

msize := 240@180.
 
p1 := PasteUpMorph new extent: msize; position: 40@40; color: Color red.
w addMorph: p1.

p2 := PasteUpMorph new extent: msize; position: 320@60; color: Color blue.
w addMorph: p2.


p3 := PasteUpMorph new extent: msize; position: 50@260; color: Color orange.
w addMorph: p3.

p4 := PasteUpMorph new extent: msize; position: 340@280; color: Color green.
w addMorph: p4.

number := 0.
offset:= 6@6.

w submorphsDo: [:p | number:= number + 1. 
		     p addMorph: 
                       ((StringMorph contents: number printString) 
                         position: (p position + offset))
               ].
					
w openInWorld.

PasteUpMorph-with-four-submorphs.png