Author Topic: UIInput OnReturnKey  (Read 2699 times)

EvilWolve

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
UIInput OnReturnKey
« 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...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput OnReturnKey
« Reply #1 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; }