0 votes

I want to color single characters in a TextEdit. Currently, it supports coloring a keyword with "addkeywordcolor()", but a keyword requires a symbol (or space) before and after to be identified, e.g. so one cannot just color all "a" easily.

I simply cannot figure out how to color a single character (or a sequence no surrounded by symbols), can anyone give some idea on how to do that?

Can I write a new function for the TextEdit which does that, maybe coloring (or setting some other font property) with regular expressions etc.

Actually, I did make a hack, by modding a font to include a zero width space and then inserting that all the time the text is changed.

Thanks in advance!

in Engine by (22 points)

1 Answer

+2 votes

I don't think TextEdit supports that, or was even meant to color single characters aribtrarily.
That's more like something you would find in RichTextLabel, although it cannot be edited by the user.
You'd have to build a custom text editor from that if your needs are simple.

Maybe this PR will help you color TextEdit in the future: https://github.com/godotengine/godot/pull/38440

by (29,120 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.