InputField onBeginEdit?

Is there some reliable way to determine when you start editing an InputField? It seems strange that this event type would be missing, when it would be so useful for UI purposes.

I’m specifically interested in this in order to lock the keyboard controls so that you don’t move around while you’re trying to type into an input field.

2 Likes

You may just be able to add a script to the inputfield field for when you click on it, it sets a bool to true so you can’t move. Otherwise, you could also grab the inputField script and look into the methods for when it gains focus and loses focus and just make some personal tweaks to the code there.

InputFields have a onvaluechange, so you could set a bool true when they type as well.

Thanks for the tips. Yeah that’s true, we do have the source code for InputField, so I may have to take a look at that…

I tried onValueChanged as well, but the problem is it doesn’t prevent that very first key from being processed elsewhere.

Clicking on it to set a bool is another idea, but I’m worried it may become stuck if I click elsewhere, unless I keep track of all clicks… worth a try I suppose if editing the source code doesn’t pan out.

Implement ISelectHandler interface, works like a charm.

3 Likes
// When InputFields have focus, they will occupy the EventSystem.current.currentSelectedGameObject property.
if (EventSystem.current.currentSelectedGameObject == null) {
  // Update movement.
}
2 Likes

Great, thanks!