I am currently implementing the rich text input which can show emotes.
So <sprite=0>
gets converted into an emote. The user sees the emote, but when he tries to remove it, it just removes the first character, which results into <sprite=0
. How can I remove the whole tag?
BUMP
Having similar issue @markalles21.
I thought about having a List of structs where I store all indexes of ‘<’ and ‘>’ so when the caret gets next to a ‘>’ if the user input is a cancel action then I remove the whole tag. The problem is that for a millisecond you can still see the beheaded tag.
Actually I’m solving this with a regex:
Regex rgx = new Regex("<(?!sprite name).*?>");
while (rgx.IsMatch(inputField.GetText()))
{
inputField.SetText(rgx.Replace(inputField.GetText(), " "));
}
This basically removes all tags besides the emojis.
But if the user moves the caret backward and inserts a tag before the text there is a problem: for a very little moment you can see the text change, then the regex comes in action and everything comes back to normal.
What I’m trying to achieve is to avoid user’s tags but I need rich text to be active for emojis.
Any better solution?