‎2021-01-05 12:15 PM
I would like to highlight a single character within the text of a flex button. In my application I have an encoder with a button, which can change the numerical value displayed in certain increments, and I would like to switch the position of the highlighted character with each button click, thus indicating that different increments are used. Nice would be something like 123456 or 123456. I actually do not care much about the method for highlighting the character, so it can be a different color, bold face, underline, whatever, as long as it is highlighted. Is there a simple way for doing this? Are there any control sequences available for the text, for example "\u" to indicate that now the text should get underlined?
‎2021-01-05 01:04 PM
Hi,
i mean you have only one way, place over next text, calculate x,y and show one highlighted char in textarea.
‎2021-01-06 01:40 AM
Hi,
I agree with MM, it is the easiest solution especialy for the higligted char: have the flex button write "abc e" and a textarea overt it with the letter you want to highlight " d ". The logic needs to be done through code to be able to navigate within the text. Here is a cursor demo I did a while back. It might help you get some inspiration on how to do your own on a flex button.
/Romain
‎2021-01-06 02:31 AM
simpler is leave "abcde" and only next "d" over
‎2021-01-06 04:16 AM
you are right as this will make sure you have the right width if you do not use a monospace font (where letters do not all have the same width and height).
‎2021-01-07 09:13 AM
I looked at the cursor example, and think I will try a different approach. I will pack the flex button in a container, use a monospace font, overlay the flex button with a text field and then write a text with an underscore character '_' at the right position.
‎2021-01-08 01:15 AM
perfect :ok_hand: Do not hesitate to share this here if other users could be interested by your solution.
/Romain
‎2021-01-08 01:26 AM
I mean your idea will not work and when you plan only underscore marking you dont need other text, only move an graphics element line .
Underscored font in your second text is used for all characters then all is underscored maybe too spaces.
‎2021-01-08 04:18 AM
yes the "abc e" idea was not for the underscore but for the highlighted character.
‎2021-01-09 11:14 AM
Overlaying the flex button with a text field worked. I was using a monospace font (Deja Vu, since that font is available in all kinds of variations, proportional and monospace). Marking the position was as easy as writing an underscore ‘_’ character into the buffer of the text field at the right position. I dropped the idea of packing this into a container, since the additional complication I am getting with the container did not outweigh the additional code I need to write if I use this method in several places. I did not check this, but in theory this method should also work for highlighting a character in a different color or with the boldface variation of the font.