Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Having some issues with InputText in Android

Discussion in 'UGUI & TextMesh Pro' started by lupidan, Sep 1, 2014.

  1. lupidan

    lupidan

    Joined:
    Jan 14, 2014
    Posts:
    47
    I have a very simple InputText to input a certain string. This code seems to work on the editor just fine, but it won't work on Android when the keyboard is dismissed, or when click Ok in the keyboard input.

    How can I detect when the user has finished setting the value for the InputField?

    Code (CSharp):
    1.  
    2.  
    3. public InputField nameInputField = null;
    4.  
    5. void Start() {
    6.   nameInputField.onSubmit.AddListener(this.NameValueInput);
    7. }
    8.  
    9. public void NameValueInput(string value) {
    10.   string regexInput = @"^\w+$";
    11.   bool isCorrect = Regex.IsMatch(value, regexInput);
    12.   if (!isCorrect) {
    13.     //Show error message
    14.   }
    15.   else{
    16.     //Save value
    17.   }
    18. }
    19.  
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    The OnSubmit should work for all devices but please report a bug so we can track/ fix it.