Skip to main content
ferro
Lead
February 17, 2023
Solved

TextArea: how to align text vertically

  • February 17, 2023
  • 9 replies
  • 4969 views

Hi,

TextArea allows to align text in horizontal direction. How to achieve the same alignment in vertical direction ?

Thanks

This topic has been closed for replies.
Best answer by Osman SOYKURT

Hello,

This subject was already treated here. This feature is not possible in TouchGFX Designer yet, but thanks for suggesting again, we could consider to add it in a future release if it's a big help for users.

/Osman

9 replies

Romain DIELEMAN
ST Employee
February 20, 2023

Hi,

Could you explain a bit more what you are trying to achieve ? I suppose you are trying to write something like in kanji/hanzi vertically and want to make sure they are aligned ? Or is it something else ?

/Romain

ferro
ferroAuthor
Lead
February 27, 2023

Hi @Romain DIELEMAN​ 

Sorry for slow reply.

"Could you explain a bit more what you are trying to achieve ?"

Yes, certainly.

When Text Area changes X dimesion text is aligned in the center automatically - horizontal alignment

0693W00000aHiuBQAS.png 

However, when Y dimension is changed text stays always at the top.

So I wonder how to achieve center and bottom text alignment - this is what I mean by "vertical alignment".

0693W00000aHiukQAC.png 

Thanks

awiernie
Associate III
March 6, 2023

I also wanted to use vertical allign. I have an error message which can be up to 3 lines large. If it is only 1 line large, it should be displayed at a lower position. As it seems not to be possible to make vertical align, I changed the vertical position by querying the size using calculateTextHeight().

ferro
ferroAuthor
Lead
March 10, 2023

"I changed the vertical position by querying the size using calculateTextHeight()"

Thanks for the hint @awiernie​ . It seems that getTextHeight () returns the same value ?

I experimented with setBaselineY () and realized that setBaselineY () is not changing text's Y position within TextArea::Drawable area but rather movig the whole Drawable.

So, with the following line, the text is not placed in the vertical center of the TextArea::Drawable but rather the whole TextArea is moved in coordinates of its parent.

TextArea::setBaselineY ( TextArea::getHeight () / 2 );

awiernie
Associate III
March 10, 2023

The difference is, that getTextHight() has no argument and it calculates the hight of the current text in the widget. With calculateTextHeight you give a text string and you get the height which would be needed to display it (taking into account line wraps). So you can decide in advance without setting the text.

Osman SOYKURT
Osman SOYKURTBest answer
ST Technical Moderator
March 14, 2023

Hello,

This subject was already treated here. This feature is not possible in TouchGFX Designer yet, but thanks for suggesting again, we could consider to add it in a future release if it's a big help for users.

/Osman

ST Software Developer | TouchGFX
ferro
ferroAuthor
Lead
March 14, 2023

Hi @Osman SOYKURT​ ,

"we could consider to add it in a future release if it's a big help for users"

Please do, thank you. Big help. I think it is a common feature (Qt::QLabel, emWin::GUI_SetTextAlign).

However, I found this very interesting comment from Martin KJELDSEN on why it was not implemented:

0693W00000aIvzaQAC.png