[Cuis-dev] LabelMorph text alignment

ken.dickey at whidbey.com ken.dickey at whidbey.com
Tue Mar 14 07:22:22 PDT 2023


On 2023-03-14 06:06, Alexandre Rousseau via Cuis-dev wrote:

> Hi all.
> 
> Given this code ...
> 
>> "self is a LayoutMorph newColumn instance"
> 
>> m := LabelMorph new :: contents: '0.0'.
> 
>> m borderWidth: 3; borderColor: Color black.
>> m layoutSpec :: proportionalWidth: 1.0.
>> self addMorph: m.
> 
> I would like the text inside m to be right-aligned.
> 
> Am I correct in assuming that there is no other way to achieve this 
> (text-alignment right) than to embed another LayoutMorph newRow 
> instance inside of self, and then embed m (the LabelMorph instance) 
> inside of that?

Probably most simple way is to subclass LabelMorph to do what you want.

Feature require: 'UI-Base-Morphs'

Then look at class #SqueezeLabelMorph

THe code should give enought hints on how to do what you want.

More fun to do it yourself.  :)

HTH,
-KenD


More information about the Cuis-dev mailing list