Skip to content

Instantly share code, notes, and snippets.

@bitinn
Created March 1, 2018 15:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Fake OnSubmit for Input Field
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace BeginHQ.Utility {
/*
redirect submit event to parent
*/
public class UISubmitInput : MonoBehaviour {
private void Awake () {
var input = gameObject.GetComponent<InputField>();
input.onEndEdit.AddListener((s) => {
HandleSubmit(input);
});
}
private void HandleSubmit (InputField input) {
var ev = new BaseEventData(EventSystem.current);
ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, ev, ExecuteEvents.submitHandler);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment