Is there a way to highlight only 1 character in a TextEdit node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IHate

I’m trying to set the highlight colour of “+” and “-” individually I would like the highlight to take effect even if the “+” is not isolated “+23”

But it seems these two methods are not working properly Did anyone have this problem before? Am I doing something wrong?

Imgur

The “-” doesn’t stop highlighting the string after the space

add_color_region("+"," ",Color.green)
add_color_region("-"," ",Color.red)

These don’t work at all:

add_keyword_color("+",Color.green)
add_keyword_color("-",Color.red)
:bust_in_silhouette: Reply From: jgodfrey

I don’t think TextEdit provides any way to arbitrarily change the color of a single “inline” (not separated) character. That said, the issue you highlight with the two add_color_region calls looks like a bug of some sort.

With your code, the - doesn’t work as you indicated. However, if you reverse the order of the assignments, the + doesn’t work. So, it seem the first assignment is ok, but the second one is bugged.

Here’s a related question, with a link to a PR that could improve the situation in the future…

https://forum.godotengine.org/70589/color-single-characters-in-textedit

You can report bugs here:

I already reported the bug I have found 4 already xd. I didn’t check if there was another issue with the same problem in this case but now I can add the new information about the second assignment not working thanks. I also mentioned on that issue thatadd_keyword_color is not working at all with symbols idk if this is intended the documentation says it will take a strings but these strings didn’t work.

IHate | 2020-11-20 01:58