cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to know when text goes to next line?

heyo
Senior

I'm using this function:

0693W00000VO7VDQA1.pngAnd I want to know when text line goes to next line. I want to get index or something when goes to second line. Is it possible?

2 REPLIES 2
Yoann KLEIN
ST Employee

Hello @heyo​ ,

I don't think that this kind of function exists natively in TouchGFX's API.

But you could try to implement it yourself with the getTextWidth() method which will enable you to know the width of the line in pixels. Then you could compare it with the TextArea's width, using the getWidth() function inherited from the Drawable class.

Otherwise, you could also try with the getStringWidth() method from the Font class.

I'm not sure which is the more efficient or clean way to do what you want, you might have to investigate a little in the API and choose what is the more convenient for you.

Hope I helped you,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX

getTextWidth() method finds widest line if it is multi-lined text. For example I have multi-line text and click on second line I want to know first lines width. I'm trying to implement that I can edit text in text area.