UI Toolkit TextField value is not set when submitting with mobile touch keyboard while .isDelayed is true

The UI Toolkit TextField’s value is not set when you submit from or close the mobile touch keyboard on iPad while the TextField’s .isDelayed is true.
This is an issue, as I have Value Changed callback for the TextField that I only want to trigger when the user submits.

On windows this isn’t an issue, because pressing enter seems to cause the TextField’s value to change to what was typed in, then the value changed callback is triggered. On the iPad, it looks like pressing done/closing the keyboard does nothing when .isDelayed is set to true (the value of the textField doesn’t change), and therefore there is also no value changed callback.

Is there anyway to use .isDelayed and have it behave like pc on the iPad, or if not, what is the best way to achieve this. I want to type into the ipad, not have the actual text field value update (you can see your current entered text in a little preview above the keyboard on the iPad), and then have the value in the text field value actually change to what you typed when you press submit or close the keyboard, (and then the value changed callback would be triggered)

The description for .isDelayed in the docs is: “If set to true, the value property isn’t updated until either the user presses Enter or the text field loses focus.” I suppose technically this matches the behaviour on iPad, since you’re not hitting ‘enter’ but ‘done’ or something, but I think what I’m experiencing isn’t a bug, then the behaviour should be changed to handled to match what happens on desktop (if I press done/close the keyboard, change the TextField’s value)

Tried changing the text field’s hideMobileInput to true, but this seems to not accept any input regardless of whether .isDelayed is true or false.

Also tried adding a callback for blur/focus out events for the text field, then inside the callback getting the text field’s touchScreenKeyboard property (which I assumed was the touchScreenKeyboard that is popped up when you tap the field), and then setting the textField’s value to the touch screen keyboard’s text property, but in both the blur and focus out callback the touchScreenKeyboard is aparently null, (either getting destroyed/hidden/inaccessible before the callback, or it’s just null/never set to begin with or something). This would’ve been an ideal workaround.

Same with Focus In event, it seems like the order of operations might be focus in > popup keyboard > type > close keyboard > focus out > blur, or more likely the touch screen keyboard is always null

Yes, TextField isDelayed does not work. Many users are not using this for runtime UI I guess. That is the reason unity is not so keen on fixing it. I stopped using isDelayed and added a seperate button to submit the text.

Good to know. I think I ended up using something like focus out to achieve a similar effect to what I described. I keep running into issues like this, so I might start doing separate buttons to submit instead. Thanks for the reply either way.

I think this is the same issue as reported here: TextField RegisterValueChangedCallback doesn't fire on devices with IsDelayed set to true - #6 by laila-chammaa

1 Like