Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: EvilWolve on June 25, 2014, 09:47:54 AM

Title: UIInput OnReturnKey
Post by: EvilWolve on June 25, 2014, 09:47:54 AM
Hello,

I'm very new to the whole Delegate concept. I don't get how to achieve this:

I have a UIInput field. When the user presses the NewLine-key, the text field is supposed to submit its contents.

So this is how I think it should work:
  1. public UIInput input;
  2. void Start()
  3. {
  4.   input.onReturnKey = SubmitMessage();
  5. }
  6.  
  7. private UIInput.OnReturnKey SubmitMessage()
  8. {
  9.   input.Submit();
  10.   return UIInput.OnReturnKey.NewLine;
  11. }

Needless to say, it doesn't. How is this system supposed to be used? Any help is much appreciated...
Title: Re: UIInput OnReturnKey
Post by: ArenMook on June 26, 2014, 09:29:19 AM
EventDelegate.Add or EventDelegate.Set
  1. EventDelegate.Set(input.onSubmit, YourFunction);
  1. void YourFunction () { Debug.Log(UIInput.current.value; }