cancel
Showing results for 
Search instead for 
Did you mean: 

Text Area and alignment

kvl
Associate II

Hi,

I am struggling with text alignment. I hoped that I could center aligning a text in a text area vertically. But it seems har to do.

I have had som fun in TouchGFX Designer aligning some texts.

0690X000009YNN7QAO.png

It is the same text in all fields, and the text areas fills the rectangles. First column is left aligned, center column is center aligned, and the right column is right aligned.

First row in text is rotation 0°, second is 180° and third is in 90°.

I do not understand the algorithm when choosing a different rotation than 0°. But it seems that the text are aligned in two independent domains:

  • Text alignment in normal reading direction.
  • Field alignment in viewing direction.

But how do I align the text in the center of a field in both horizontal and vertical direction? It seems only possible if you choose 90° rotation. (and probably also 270°)

If you ask me, there should be independent horizontal and vertical alignment settings.

Here is an example from emWin (GUI builder in last century style):

0690X000009YNRxQAO.png

BR

Kasper

5 REPLIES 5
Martin KJELDSEN
Chief III

Hi,

There's no api function to align a text vertically. You have to do this manually, currently, using getTextHeight() and also measuring the space above the text to the "ceiling" of your textarea. Someone else here just had the same issue, let me try to find the post for you.

/Martin

kvl
Associate II

Hi Martin

Thanks. I was looking forward for a better solution. This is definitely TouchGFX must do better in the future. Just lik my other post:

https://community.st.com/s/question/0D50X0000B2AQR3SQO/texturemapper-and-orientationportrait

Kasper

Martin KJELDSEN
Chief III

I will try to confirm the texturemapper-in-portrait-mode tomorrow :) The reason why we haven't done vertical centering, i think, is because its a little odd to do. Application developers are usually told to put things at certain coordinates from their UX people - This is difficult to achieve using centering. Sometmies it makes sense to horizontally, but almost never vertically.

/Martin

Sorry to necro, but this is a serious deficiency. Basically we have to calculate the position of *every* screen element that's not edge-justified. Even "static" text is variable size when you consider almost every use will have localized variants. Maybe we're supposed to create a different text element for every localized version of a string, show / hide them, and position them statically? I hope not.

Vertical centering is a thing also.