I'm aware of detecting when new text is added to a TextBox, however I'd like to know if it's possible to get the appended text directly. I'm only asking because in my circumstance, text inside my TextBox is both ahead, and behind where the user input is focused (eliminating the option to sub(-1) for the newest character appended). Anyway, here are some ideas and things I've tried:
I've also tried using other input events such as InputBegan
and InputChanged
(opposed to just using the Changed
), but it doesn't seem to detect any keyboard input with a TextBox.
If there isn't a simple built-in solution of getting appended text directly, I was thinking about creating something that can find the difference between two text messages. For example:
--> Input -- arg #1 being original text -- arg #2 being altered text func("testing 123", "testing-123") --> Output > "-"
That way it wouldn't matter where the text is being appended to, it would just return characters that are inconsistent with the previous change. Either way, I'd love to hear other opinions, ideas, and suggestions, or if I'm just overlooking something very blatant. Thanks.
You're not looking for appended text, since appended means adding to the end.
Your best option here would be running a diff algorithm on both versions of the text manually. You could try reading this PDF about Myer's diff algorithm mentioned by @BlackJPI and implementing that. (Yay for learning code from PDFs! )