Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: arkon3 on November 26, 2013, 08:34:34 PM

Title: UIInput onSubmit not working
Post by: arkon3 on November 26, 2013, 08:34:34 PM
I'm using Unity 3.5.7 and can't get a UIInput to call it's delegate onSubmit functions.
I've put a breakpoint in UIInput.cs on the Submit function and it never gets called. I've filled in the component correctly, it just doesn't get called. (This is in the editor with OSX as the target)

Further debugging: in the UIInput OnGUI function it breaks on the "if" line but never breaks on the processEvent line.

  1. void OnGUI ()
  2.         {
  3.          Debug.Log("isSelected " + isSelected + "Event " + Event.current);
  4.          if (isSelected && Event.current.rawType == EventType.KeyDown)
  5.                         ProcessEvent(Event.current);
  6.         }

Here is the output from the log when typing "hello" + Return

isSelected TrueEvent Layout
isSelected TrueEvent Repaint
isSelected TrueEvent Event:KeyUp   Character:\0   Modifiers:0   KeyCode:H
isSelected TrueEvent Event:KeyUp   Character:\0   Modifiers:0   KeyCode:E (etc)
isSelected TrueEvent Event:KeyUp   Character:\0   Modifiers:0   KeyCode:Return <<<<<error

As you can see your code expects a keydown event but never gets one, it does get a keyup event instead.
Title: Re: UIInput onSubmit not working
Post by: ArenMook on November 26, 2013, 11:54:27 PM
Seems to work fine here... I created the following script:
  1. using UnityEngine;
  2.  
  3. public class Test : MonoBehaviour
  4. {
  5.         public void MySubmit ()
  6.         {
  7.                 Debug.Log("Text: " + UIInput.current.value);
  8.         }
  9. }
I then attached it to an object, dragged that object into the Notify field in UIInput's OnSubmit section, and chose "Test.MySubmit" as the method. When I type and hit Return the Debug.Log is printed in both Unity 3.5.7 and 4.3.0. What platform are you using?
Title: Re: UIInput onSubmit not working
Post by: arkon3 on December 05, 2013, 07:53:32 PM
Hi, sorry didn't realise you replied. It still doesn't work for me unless I change your code to KeyUp.

I'm using Unity 3.5.7, NGUI 3.04, Target PC & Mac standalone with Mac OSX selected. Development machine is a Mac using OSX 10.8.5

I get normal Keydown events when using unity's Input class, just not being sent from your event code.

Title: Re: UIInput onSubmit not working
Post by: Darkmax on December 05, 2013, 08:16:32 PM
try to update to the latest version of ngui 3.0.6 maybe that could be.
Title: Re: UIInput onSubmit not working
Post by: ArenMook on December 06, 2013, 04:07:09 AM
Yeah as a rule of thumb, always update to the latest version before posting bug reports. Chances are they've already been fixed.
Title: Re: UIInput onSubmit not working
Post by: quitebuttery on January 03, 2014, 04:46:15 PM
So I kind of have this same problem with the latest version.  I put a breakpoint at line 908 and 910 of UIInput for the Submit method and it's never getting called when I hit enter in the editor--thus my OnSubmit delegate is never getting called.  Is there something I'm missing in the settings to get UIInput to fire off a Submit event when enter is hit in the editor, even though the build target platform is iOS?
Title: Re: UIInput onSubmit not working
Post by: quitebuttery on January 03, 2014, 05:39:10 PM
Just to reply to myself.  I had to set MaxLines to 1--otherwise enter will just do a newline and not a submit.  DUH!  Oh well, carry on! :)