Hi all,
I’ve searched all the day long to make this one.
I’d like to be able, in script, to add listeners to validation or cancelation of the input field after the user typed some text. I tried with onSubmit but as lots of already said, it’s not working for every cases.
And I tried to play with the ICancelHandler but didn’t get better result.
Any help is welcome.
There is no message for cancellation of the input field but there is the onValidateInput delegate that you can assign a listener to
Thanks, I’ll try to play with OnDeselect.
Regarding onValidateInput, I can’t add a listener to it.
void Awake()
{
GetComponent<InputField>().onValidateInput.AddListener( Validated );
}
void Validated(string _value, int index, char car )
{
print ("validated" );
}
Throws the error :
Assets/Plugins/Test.cs(12,60): error CS1061: Type UnityEngine.UI.InputField.OnValidateInput' does not contain a definition for
AddListener’ and no extension method AddListener' of type
UnityEngine.UI.InputField.OnValidateInput’ could be found (are you missing a using directive or an assembly reference?)
right because its not a UnityEvent its a C# Delegate. you need to do
GetComponent().onValidateInput = Validated;