Spec - Text alignment in LabelModel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Spec - Text alignment in LabelModel

nacho
Hi,
After spending almost two hours digging into Spec I couldn't figure out how to change the alignment of the text in LabelModel. As I'm building a simple calculator, the text has to be right-aligned. The default is left-alginement which makes the calculator display look weird.
Any help would be much appreciated.
best regards
Nacho
 
Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Spec - Text alignment in LabelModel

Clément Béra
Hey,

I'm not sure this is the good way to do it, but you can store in your labelModel a Text instead of a String:

myComposableModel label text: 'someString' asText.

Then you can add attribute to the text:

myComposableModel label text addAttribute: TextColor red.
myComposableModel label text addAttribute: TextAlignment rightFlush.

Try first with TextColor red, because for TextAlignment rightFlush there might be other reason it does not work 
(i.e. the label model has the width of the text, so modifying the alignment will not modify anything).

Best,


2013/11/7 nacho <[hidden email]>
Hi,
After spending almost two hours digging into Spec I couldn't figure out how
to change the alignment of the text in LabelModel. As I'm building a simple
calculator, the text has to be right-aligned. The default is left-alginement
which makes the calculator display look weird.
Any help would be much appreciated.
best regards
Nacho





-----
Nacho
Smalltalker apprentice.
Buenos Aires, Argentina.
--
View this message in context: http://forum.world.st/Spec-Text-alignment-in-LabelModel-tp4719750.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Spec - Text alignment in LabelModel

Clément Béra
I checked it seems that TextAlignment is currently broken. Only other text attributes work. sorry.


2013/11/7 Clément Bera <[hidden email]>
Hey,

I'm not sure this is the good way to do it, but you can store in your labelModel a Text instead of a String:

myComposableModel label text: 'someString' asText.

Then you can add attribute to the text:

myComposableModel label text addAttribute: TextColor red.
myComposableModel label text addAttribute: TextAlignment rightFlush.

Try first with TextColor red, because for TextAlignment rightFlush there might be other reason it does not work 
(i.e. the label model has the width of the text, so modifying the alignment will not modify anything).

Best,


2013/11/7 nacho <[hidden email]>
Hi,
After spending almost two hours digging into Spec I couldn't figure out how
to change the alignment of the text in LabelModel. As I'm building a simple
calculator, the text has to be right-aligned. The default is left-alginement
which makes the calculator display look weird.
Any help would be much appreciated.
best regards
Nacho





-----
Nacho
Smalltalker apprentice.
Buenos Aires, Argentina.
--
View this message in context: http://forum.world.st/Spec-Text-alignment-in-LabelModel-tp4719750.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|

Re: Spec - Text alignment in LabelModel

nacho
Yes, it is.
Thanks anyway. I'm still trying to figure out  this... ;)
nacho


Lic. Ignacio Sniechowski, MBA







On Thu, Nov 7, 2013 at 7:36 PM, Clément Bera <[hidden email]> wrote:
I checked it seems that TextAlignment is currently broken. Only other text attributes work. sorry.


2013/11/7 Clément Bera <[hidden email]>
Hey,

I'm not sure this is the good way to do it, but you can store in your labelModel a Text instead of a String:

myComposableModel label text: 'someString' asText.

Then you can add attribute to the text:

myComposableModel label text addAttribute: TextColor red.
myComposableModel label text addAttribute: TextAlignment rightFlush.

Try first with TextColor red, because for TextAlignment rightFlush there might be other reason it does not work 
(i.e. the label model has the width of the text, so modifying the alignment will not modify anything).

Best,


2013/11/7 nacho <[hidden email]>
Hi,
After spending almost two hours digging into Spec I couldn't figure out how
to change the alignment of the text in LabelModel. As I'm building a simple
calculator, the text has to be right-aligned. The default is left-alginement
which makes the calculator display look weird.
Any help would be much appreciated.
best regards
Nacho





-----
Nacho
Smalltalker apprentice.
Buenos Aires, Argentina.
--
View this message in context: http://forum.world.st/Spec-Text-alignment-in-LabelModel-tp4719750.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




Nacho Smalltalker apprentice. Buenos Aires, Argentina.