For some reason the below Debug Log doesn't ever fire
if (customInputField.isFocused) {
if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Check");
}
}
It's located within the update method. Removing the check for the return key makes the Debug Log fire repeatedly (when the field is focussed). Could the input field be losing focus when the enter key is pressed, and if so how could I achieve this check?
CodePudding user response:
I think the return key is bind to the OnSubmit event on the field. One way is to override it or use something like this:
void Start()
{
customInputField.onSubmit.AddListener(e =>
{
if (customInputField.isFocused)
{
Debug.Log("Check");
}
});
}