0 votes

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?

https://imgur.com/Hlriapg

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)
in Engine by (388 points)

1 Answer

+1 vote
Best answer

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://godotengine.org/qa/70589/color-single-characters-in-textedit

You can report bugs here:

https://github.com/godotengine/godot/issues

by (10,856 points)
selected by

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.

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 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 webmaster@godotengine.org with your username.