WX-Game1/Assets/Scripts/WXInputFieldAdapterFriend.cs

96 lines
2.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
// using WeChatWASM;
[RequireComponent(typeof(InputField))]
public class WXInputFieldAdapterFriend : MonoBehaviour,IPointerClickHandler, IPointerExitHandler
{
private InputField _inputField;
private bool _isShowKeyboard = false;
private void Start()
{
_inputField = GetComponent<InputField>();
}
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("OnPointerClick");
// ShowKeyboard();
}
public void OnPointerExit(PointerEventData eventData)
{
Debug.Log("OnPointerExit");
if (!_inputField.isFocused)
{
// HideKeyboard();
}
}
// private void OnInput(OnKeyboardInputListenerResult v)
// {
// Debug.Log("onInput");
// Debug.Log(v.value);
// if (_inputField.isFocused)
// {
// _inputField.text = v.value;
// }
//
// }
//
// private void OnConfirm(OnKeyboardInputListenerResult v)
// {
// // 输入法confirm回调
// Debug.Log("onConfirm");
// Debug.Log(v.value);
//
// HideKeyboard();
// }
//
// private void OnComplete(OnKeyboardInputListenerResult v)
// {
// // 输入法complete回调
// Debug.Log("OnComplete");
// Debug.Log(v.value);
//
// // chatPanelManager.AddBubble(v.value,Random.Range(0,2)>0);
//
// HideKeyboard();
// }
//
// private void ShowKeyboard()
// {
// if (_isShowKeyboard) return;
//
// WX.ShowKeyboard(new ShowKeyboardOption()
// {
// defaultValue = "",
// maxLength = 100,
// confirmType = "send"
// });
//
// //绑定回调
// WX.OnKeyboardConfirm(this.OnConfirm);
// WX.OnKeyboardComplete(this.OnComplete);
// WX.OnKeyboardInput(this.OnInput);
// _isShowKeyboard = true;
// }
//
// private void HideKeyboard()
// {
// if (!_isShowKeyboard) return;
//
// WX.HideKeyboard(new HideKeyboardOption());
// //删除掉相关事件监听
// WX.OffKeyboardInput(this.OnInput);
// WX.OffKeyboardConfirm(this.OnConfirm);
// WX.OffKeyboardComplete(this.OnComplete);
// _isShowKeyboard = false;
// }
}