cancel
Showing results for 
Search instead for 
Did you mean: 

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

AJT141
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Romain DIELEMAN
ST Employee

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

View solution in original post

2 REPLIES 2
Romain DIELEMAN
ST Employee

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

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