How to change the position of the backup

I have two morphs that are in another.

a:= Morph new.
b:= Morph new. 
a addMorph: b. 
a openInWorld.

but when I want to change position b by doing position b: 100 @ 100, it never shows the change, so what am I missing here? or is it somehow an obligation to track position b?

+5
source share
1 answer

This should work:

| morph1 morph2 |

morph1 := Morph new.
morph1 color: Color red.
morph1 extent: 200@200.

morph2 := Morph new.
morph2 color: Color green.
morph2 extent: 50@50.

morph1 addMorph: morph2.
morph2 position: 100@100.
morph1 openInWorld.

Result:

enter image description here

Note that the positions are absolute, if you want relative positions, you should do something like:

morph2 position: (morph1 position + (100@100))

If you add Morphs to the window, you can take a look at SystemWindow #addMorph: fullFrame: which offers the best options for positioning subfiles. Morph also implements #addMorph: fullFrame: but for some reason this doesn't work for me in Pharo 2.0.

: Pharo CollActive book " " 2.

+6

All Articles