Detect Submit on Android

Hi guys. I’m trying to detect submit on inputfield. I found this code;

import UnityEngine.UI;

public var myInput : InputField;

function Start(){
    myInput.onSubmit.AddListener(myInputSubmit);
}

function myInputSubmit(){
    Debug.Log("test");
}

It’s work on desktop, but not works on Android. How can handle this?

Not sure what you are looking for but you could leverage:

if (GUI.changed) {
    Debug.Log("Text field has changed.");
    // do something
}

I’m looking for this buttons click event;

1755949--111131--Untitled-1.jpg

Or might be keyboard close event, if is exists :slight_smile: Thank you for reply :slight_smile:

Thank you man, you are awesome! :smile:
Here is my code; I used Text instead of InputField.
You must be call openKeyboard function on myText clicked.

import UnityEngine.UI;

public var myText : Text; // this your input field

private var Keyboard : TouchScreenKeyboard;
private var isKeyboardOpen : boolean;
private var KeyboardText : String = ""; // default text

function openKeyboard(){
    Keyboard = TouchScreenKeyboard.Open(KeyboardString, TouchScreenKeyboardType.Default);
    isKeyboardOpen = true;
}

function Update(){
    if(isKeyboardOpen && Keyboard){
           if (Keyboard.done){
            //keyboard submitted
            isKeyboardOpen = false;
            myText.text = KeyboardText;
            //do your staff
           }
        if(Keyboard)
            KeyboardText = Keyboard.text;
   }
}
1 Like