Login  Register

Morphs with Spec2

Posted by Sebastian Jordan on Mar 18, 2020; 4:41pm
URL: https://forum.world.st/Morphs-with-Spec2-tp5113524.html

Hi everyone,

I Want to use a StringMorph as a title of a UI created with Spec2. For that, I am using a SpMorhPresenter inside a SpPresenter. But the text inside the morph loses its format as it is shown in the attached image.
Does anyone knows how to solve this? What I am doing wrong?
It would be very appreciated. Thanks for your time.

Here is the code of the example:

defaultSpec
  ^ SpBoxLayout newVertical
    add: #morphLabel;
    add: #button1;
    add: #button2;
    yourself

initializePresenters
    morphLabel := self obtainSpMorphPresenterwithAStringMorph.
    button1 := self newButton.
    button1 label: 'Button one'.
    button2 := self newButton.
    button2 label: 'Button two'.
    self focusOrder
        add: morphLabel;
        add: button1;
        add: button2

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: morph;
    yourself

example.jpg (41K) Download Attachment