cancel
Showing results for 
Search instead for 
Did you mean: 

Text Area Widgets in Touchgfx

Hafsa
Visitor

Hello!

This is written that Touchgfx widget 'Text Area' if has enabled the action 'WIDE_TEXT_WORDWRAP' then the call 'getTextWidth()' will return the width of the widest line but it returns the width of the total text area.
Can you please check how to improve this?

Thanks in advance!
Best Regards
Hafsa

2 REPLIES 2
GaetanGodart
ST Employee

Hello @Hafsa and welcome to the community!

 

I am not sure I understand what you want to achieve.

I have created a textArea, set its width manually to 300 and wrote a text longer than 300 pixels, I have also put the textArea behavior to "wrap between words".
I run this function when clicking the button :

virtual void function1()
    {
        touchgfx_printf("Size before WIDE_TEXT_WORDWRAP : %d\n", textArea1.getTextWidth());
        textArea1.setWideTextAction(WIDE_TEXT_WORDWRAP);
        touchgfx_printf("Size after WIDE_TEXT_WORDWRAP  : %d\n", textArea1.getTextWidth());
    }

And I get this result :

GaetanGodart_0-1742477566135.png

So with or without WIDE_TEXT_WORDMAP, the result is the length of the text, not the length of the textArea.

 

Perhaps you can share your project so I can see what you have done!

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Hafsa
Visitor

Hello!

Thanks for the reply.
I need to set the x,y position of the text on the flex button, text position should be dynamic and I read from the method definition that

/**

* Gets the width in pixels of the current associated text in the current selected

* language. In case of multi-lined text the width of the widest line is returned.

*

* @return The width in pixels of the current text.

*/
virtual uint16_t getTextWidth() const;


So if the text width is 300 pixel in single line and the same text but in other language has

width 450 and the multiline feature is enabled so i assume that it should return me

the length of the widest line and say if the widest line 280 pixels, then this call should

return 280 pixels and not the 450. Then it will be easy for me to set the position x and y
for the text.
Am I missing something here?

Best Regards
Hafsa