InputField iOS keyboard problem

Hi,

I have a input field that I only want to submit when I press “return” key or a button in the UI. In iOS when we focus the input field the iOS keyboard opens. That keyboard have a “done” and a “enter” buttons and I would like also to submit when the user press those.

My question is how do I access those buttons? I research a bit about this but not getting luck. In docs I saw this: Unity - Scripting API: TouchScreenKeyboard.done

The class InputField has the keyboard that TouchScreenKeyboard.Open returns but it’s not accessable.

Thanks

If you want to access some functionality of the Keyboard the the InputField opens up one solution could be to tweak Keyboard.mm in the Generated XCode files?

You can also look into using the events that are generated by the InputField. There is an event called OnSubmit - but I havent used it myself yet so i dont know if that’s the exact thing out want to subscribe on.

Hi,I solve the problem when press “return” to call a event in iOS。

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine.Events;
using System;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;

public class SubmitInputField : InputField
{
    [Serializable]
    public class KeyboardDoneEvent : UnityEvent { }

    [SerializeField]
    private KeyboardDoneEvent m_keyboardDone = new KeyboardDoneEvent();

    public KeyboardDoneEvent onKeyboardDone
    {
        get { return m_keyboardDone; }
        set { m_keyboardDone = value; }
    }

    void Update()
    {
        if (m_Keyboard != null && m_Keyboard.done && !m_Keyboard.wasCanceled)
        {
            m_keyboardDone.Invoke();
        }
    }
}
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEngine.UI;
using UnityEditor.UI;

[CustomEditor(typeof(SubmitInputField), true)]
[CanEditMultipleObjects]
public class SubmitInputFieldEditor : InputFieldEditor
{
    SerializedProperty m_KeyboardDoneProperty;
    SerializedProperty m_TextComponent;

    protected override void OnEnable()
    {
        base.OnEnable();
        m_KeyboardDoneProperty = serializedObject.FindProperty("m_keyboardDone");
        m_TextComponent = serializedObject.FindProperty("m_TextComponent");
    }


    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null);

        EditorGUILayout.Space();

        serializedObject.Update();
        EditorGUILayout.PropertyField(m_KeyboardDoneProperty);
        serializedObject.ApplyModifiedProperties();

        EditorGUI.EndDisabledGroup();
        serializedObject.ApplyModifiedProperties();
    }
}

But In Android,the code don’t work,and the onKeyboardDone same to OnEndEdit(In Android)