cancel
Showing results for 
Search instead for 
Did you mean: 

Can we have different color for different characters in a text?

BParh.1
Senior III

So assume I define a text area widget which contained text "123". Can we have e.g. color gray for character '1', color black for character '2' and color red for character '3'?

The usage is e.g. to take user input via numpad, and we want to show user which character has been edited, just edited and going to be edited accordingly.

1 ACCEPTED SOLUTION

Accepted Solutions
Paul1
Lead

Doubtful

Try: Overlapping textboxes

  • top one has the highlighted colour
  • fixed width font same in both so spaces and chars align
  • option: bold in the "edit char text box", but that may cause spaces to be wider and mess up spacing

Try: single char edit box, with origin moved to position it over the "edit char"

  • easier with fixed width font in main text box (theoretically could support variable width font if you make a table of "char widths" to calculate origin)
  • Bonus: Can use bold and colour for edit char as don't depend on width of spaces
  • Bonus: Can also use reverse font (black on grey instead of white on black), can even alternate the reverse normal font for blinking edit char effect.
  • Bonus: Text box doesn't need to be transparent since doesn't rely on transparent spaces to show text behind

Try: Overlapping rectangle that hovers over "edit character", no change to text box, just highlights or blinks on the selected edit char

  • easier if fixed width font

Paul

View solution in original post

2 REPLIES 2
Paul1
Lead

Doubtful

Try: Overlapping textboxes

  • top one has the highlighted colour
  • fixed width font same in both so spaces and chars align
  • option: bold in the "edit char text box", but that may cause spaces to be wider and mess up spacing

Try: single char edit box, with origin moved to position it over the "edit char"

  • easier with fixed width font in main text box (theoretically could support variable width font if you make a table of "char widths" to calculate origin)
  • Bonus: Can use bold and colour for edit char as don't depend on width of spaces
  • Bonus: Can also use reverse font (black on grey instead of white on black), can even alternate the reverse normal font for blinking edit char effect.
  • Bonus: Text box doesn't need to be transparent since doesn't rely on transparent spaces to show text behind

Try: Overlapping rectangle that hovers over "edit character", no change to text box, just highlights or blinks on the selected edit char

  • easier if fixed width font

Paul

BParh.1
Senior III

Thanks @Community member​ , I chose the third option.