- Home /
InputField "bug" editing text before last symbol
Hello I have found 1 thing, which is very annoying. I am not sure, is it bug or not, but anyway I didnt find any solution So, If to edit text in GameObject with InputField and Text components, putting cursor before last character in text field, then remove all previous symbols (Backspace) and enter new value, the last character (which is positioned after mouse cursor) will hide and reveal only after EndEdit event. In practice that mean - if we got value 1580 in text field, and we want to change it to 2550, we put cursor between 8 and 0, remove 1 and 5, enter 255, and we see that value in text field is not a 2550, but 255. Of course we adding one more 0, and after finish editing get 25500 instead of 2550... Does someone know how to fix it?
You don't need to remove the start of the string to get the problem, even setting the caret before the last character and typing anything will hide the last character - and people will inevitably add the missing character, potentially invalidating the input. I have not found a solution to this problem yet, anyone?
Answer by bakwards · Jun 17, 2015 at 10:00 AM
I found a solution! I have NO idea why this works exactly!
On Value Change for the input field, I add this function referencing the Input Field:
public void FixString(InputField target){
target.lineType = InputField.LineType.MultiLineSubmit;
target.textComponent.SetAllDirty();
target.lineType = InputField.LineType.SingleLine;
}
The last character is left untouched and I can stay in singleline! Weird stuff!
For information: This bug is fixed (not reproduceable) in 5.5.3f1
Answer by bakwards · Jun 17, 2015 at 10:00 AM
If I change the Line Type of the Input Field to any Mutli Line type, the problem goes away - but I'd like to not have the problem on single lines either...