cancel
Showing results for 
Search instead for 
Did you mean: 

How to make cursor for multi text lines? (keyboard)

heyo
Senior

0693W00000UnPesQAF.png

10 REPLIES 10
Osman SOYKURT
ST Employee

Hello heyo,

I'm not sure what you want to do. Can you be a more specific in your question ?

If you just want to add a cursor to your text, I'm going to say to simply use the vertical line symbol ( | ) at the end of you text like this :

0693W00000UnpbpQAB.png0693W00000UnpcJQAR.pngI'm using the keyboard widget shared in this post and I only modified the TextArea to add the vertical bar like this :

0693W00000UnpdvQAB.png/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
heyo
Senior

@Osman SOYKURT​  I want that my cursor position changes when I touch anywhere in the text. If I touch in the middle of the text it appears in the middle in the text and then I can edit text. And I want to ask another question. Is it possible to know a coordinate of writeable text?

heyo
Senior

@Osman SOYKURT​  also I use textArea.setWideTextAction(WIDE_TEXT_WORDWRAP_ELLIPSIS_AFTER_SPACE); function. Is it possible to know when text goes to next line?

We don't have a particular trigger for that in our API, but this is easily doable with an handleTickEvent() function combined with a getTextHeight() function. You first get the text heigh of your text when your application starts and then compare the the current height with the original height

Something like this :

getTextHeight

void Screen1View::setupScreen()
{
    originalSize = textArea1.getTextHeight();
}
void Screen1View::handleTickEvent()
{
    currentSize = textArea1.getTextHeight();
    if (currentSize > originalSize)
    {   
        // Added one line
        originalSize = currentSize;
    }
    else if (currentSize < originalSize)
    {   
        // Removed one line
        originalSize = currentSize;
    }
    else if (currentSize == originalSize)
    {
        // still same line number
    }
}

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
heyo
Senior

@Osman SOYKURT​ This function "textArea1.getHeight() " returns defined textArea1 height, so its always be the same and does not change.

heyo,

it's getTextHeight() not getHeight() 😉

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

And btw, if your TextArea is "autosized" then a getHeight() won't be the same if you change if you add lines.

Osman SOYKURT
ST Software Developer | TouchGFX

I saw that @Yoann KLEIN​ was helping you on this post. The provided solution is not working ?

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
heyo
Senior

@Osman SOYKURT​ Thanks.