如何统一调用onEndEdit输入字段或确定按钮的方法?

问题描述 投票:0回答:1

我在我的应用程序中有一个用于搜索词的InputField,这是团结一致开发的。

在android移动设备上,我需要查找用户单击“确定”或“完成”的时间,或编辑输入字段末尾以调用进行搜索的方法。

enter image description here

c# unity3d input-field
1个回答
0
投票

确定,尝试许多代码和文件后!解决了它:

public void Start()
{
    //Adds a listener that invokes the "LockInput" method when the player finishes editing the main input field.
    //Passes the main input field into the method when "LockInput" is invoked
    termInputField.onEndEdit.AddListener(delegate { LockInput(termInputField); });
}


void LockInput(TMP_InputField input)
{
    if (input.text.Length > 2)
    {
        Debug.Log("Text has been entered");
        DoSearch();
    }
    else if (input.text.Length == 0)
    {
        Debug.Log("Main Input Empty");
    }
}



public void DoSearch()
    {
//My Code For Doing Search!
}
© www.soinside.com 2019 - 2024. All rights reserved.