Skip to main content
AJT141
Associate III
October 22, 2020
Solved

[TouchGFX] Is it possible to apply highlighting on a textArea's Letter ?

  • October 22, 2020
  • 1 reply
  • 824 views

Hello,

I'm wondering if it is possible to apply highlighting on a letter of a textarea. Indeed, I want to notify user that is modifying one particular letter of a text area.

Any idea of how we can do that with TouchGFX library ? (problem is that we can't know where are located letters and there isn't the same spacing between each letter in the typography used in my application)

Best regards,

AJT141

This topic has been closed for replies.
Best answer by Romain DIELEMAN

Hi,

I did a cursor example a while back, might be useful. Can you change your font to a monospace version? This will make sure that the spacing between letters is always the same.

Another idea, but which could be a bit annoying I recon, could be to use 2 or 3 text areas where one has the text before the highlighted letter, one with just that letter and the other one with the text on its right. Kind of like this: for the sentence "This is my text" with "m"highlighted

text area 1: "This is "

text area 2: "m"

text area 3: "y text"

Since you can get the width of a text with nameOfTextArea.getTextWidth() you can just modify the position of the 3 text areas accordingly.

Hope this helps

/Romain

1 reply

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
October 22, 2020

Hi,

I did a cursor example a while back, might be useful. Can you change your font to a monospace version? This will make sure that the spacing between letters is always the same.

Another idea, but which could be a bit annoying I recon, could be to use 2 or 3 text areas where one has the text before the highlighted letter, one with just that letter and the other one with the text on its right. Kind of like this: for the sentence "This is my text" with "m"highlighted

text area 1: "This is "

text area 2: "m"

text area 3: "y text"

Since you can get the width of a text with nameOfTextArea.getTextWidth() you can just modify the position of the 3 text areas accordingly.

Hope this helps

/Romain

AJT141
AJT141Author
Associate III
October 22, 2020

Ok I had this idea to create three TextArea but i think I'm going to use a special font when the cursor is needed.

Thanks a lot for the example, you rock.

AJT141