Richtext and TextBox focus

Ello’

I have recently run into an issue where rich text is not being translated properly when I focus on a textbox and when I lost focus on the textbox

https://gyazo.com/b673a42ef7c9a34df3c4f67b4acd3185

Here is my code, CodeBox is the textbox and I am looping through every character

local FirstHalf = string.sub(CodeBox.Text,1, i, i -1)
local SecondHalf = string.sub(CodeBox.Text,i + 2)
CodeBox.Text = FirstHalf.."<b><font color=\"rgb(115, 204, 20)\">if</font></b>"..SecondHalf

Any help is greatly appreciated.

Apologies, but I’m not quite sure I understand the issue here. Are you referring to the fact that all the formatting is lost when you focus on the text box? This is intentional. When a user focuses on text boxes, they’ll be editing the original XML string and it’ll parse when focus is lost.

You can read more on the RichText release announcement under TextBox behaviour:

If this isn’t it, would be appreciated if you could clarify what’s wrong here. Tried reading the thread over a couple of times but not sure I get what is being asked.

2 Likes

Ah so that is how it’s supposed to be. Is there a way to make it so it is always formatted instead of displaying html?

Using RichText, no, there’s no way to retain the formatting applied to the string.

1 Like