Fake OnSubmit for Input Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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