2023-02-17 12:48 PM
Hi,
TextArea allows to align text in horizontal direction. How to achieve the same alignment in vertical direction ?
Thanks
Solved! Go to Solution.
2023-03-14 05:54 AM
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
2023-02-19 07:19 PM
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
2023-02-27 01:35 AM
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
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".
Thanks
2023-03-06 05:32 AM
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().
2023-03-10 08:39 AM
"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 );
2023-03-10 01:54 PM
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.
2023-03-13 05:06 AM
"I changed the vertical position by querying the size using calculateTextHeight()."
I thought about a variation to your approach:
TextArea::resizeHeightToCurrentText ();
TextArea::centerY ();
2023-03-14 05:54 AM
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
2023-03-14 07:13 AM
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:
2023-03-14 07:19 AM
And thank you for the link ! Here is collection of related posts I found:
How to make a Text to be align centered vertically ?
It is unfortunate that they are not listed when searching the forum (with 'align' or 'alignment'):