R. Mark Volkmann wrote:
> I'm trying to learn basic Morphic. Can someone tell me why the following code
> results in buttons labelled 1 through 4 from right to left instead of left to
> right? Any comments about this code are welcomed!
The buttons are right to left because by default morphs are added to the
front (first) and the layout computes left-to-right. As a consequence,
you need to use #addMorphBack: to include the morph to the right.
Cheers,
- Andreas
> | panel |
>
> panel := Morph new.
> panel
> layoutPolicy: TableLayout new;
> listDirection: #leftToRight;
> hResizing: #shrinkWrap;
> vResizing: #shrinkWrap;
> layoutInset: 30;
> cellInset: 10.
>
> "Why are buttons added in reverse order?"
> (1 to: 4) do: [:i |
> | button |
> button := PluggableButtonMorph
> on: [Transcript show: 'pressed'; cr]
> getState: nil
> action: #value.
> "Why is the color ignored?"
> button color: Color yellow; label: 'Button #', i asString.
> panel addMorph: button
> ].
>
> panel openInWindowLabeled: 'Mark''s Morphic Demo'
>