Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can a TextBox return any information about appended text (directly)?

Asked by 7 years ago
Edited 7 years ago

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:

Input Objects

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.

Text comparator

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.

0
Are you looking for any arbitray changes each time the focus is lost, or input between two specific strings? BlackJPI 2658 — 7y
0
Basically, I'm just looking for a way to detect and return a change such as this: https://gyazo.com/14a6ba2512f351b4974b3635d797159c. I've developed something to handle returning the change, however I'd much rather use a built-in method if one is available. ScriptGuider 5640 — 7y
0
So in that example, ROBLOX would return some data that represents the key "o" ScriptGuider 5640 — 7y
0
There is no built in method, and the problem is quite tricky. Myer's diff algorithm is probably the fastest algorithm you'll find, but it isn't overly trivial. https://neil.fraser.name/software/diff_match_patch/myers.pdf BlackJPI 2658 — 7y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
7 years ago

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! )

Ad

Answer this question