Login  Register

Re: Morphs with Spec2

Posted by Sven Van Caekenberghe-2 on Mar 19, 2020; 9:57am
URL: https://forum.world.st/Morphs-with-Spec2-tp5113524p5113542.html

But I think he wants to know how he can use Spec2 to add a centred title.
That should be possible without falling back to older stuff, right ?

> On 19 Mar 2020, at 10:25, Esteban Lorenzano <[hidden email]> wrote:
>
> Hi,
>
> 1. Spec styles define a “default” font applied to all components (morphs in this case) that understand font, and if you want to change it you need to define your own style.
> 2. A string morph cannot center the string (this is a morphic stuff)
>
> You can solve your problem by adding a PanelMorph instead a string:
>
> obtainSpMorphPresenterwithAStringMorph
>     | morph |
>     morph := StringMorph
>     contents: 'A String Morph'
>     font:
>         (LogicalFont
>             familyName: Smalltalk ui theme labelFont familyName
>             pointSize: Smalltalk ui theme labelFont pointSize + 10).
>     ^ SpMorphPresenter new
>     morph: (PanelMorph new
> addMorphBack: morph;
> yourself);
>     yourself
>
>
> This will produce this morph:
>
> <Screenshot 2020-03-19 at 10.24.01.png>
>
>
> And since I hate morphic, I will let you to fight with morph to center your sub morph ;)
>
> Esteban
>
>> On 18 Mar 2020, at 17:41, Sebastian Jordan <[hidden email]> wrote:
>>
>>
>>     button1 := self newButton.
>