From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/UICommon/XUIInput.cs | 106 +++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 Client/Assets/Scripts/UICommon/XUIInput.cs (limited to 'Client/Assets/Scripts/UICommon/XUIInput.cs') diff --git a/Client/Assets/Scripts/UICommon/XUIInput.cs b/Client/Assets/Scripts/UICommon/XUIInput.cs new file mode 100644 index 00000000..45f23042 --- /dev/null +++ b/Client/Assets/Scripts/UICommon/XUIInput.cs @@ -0,0 +1,106 @@ +using UILib; +using UnityEngine; + +public class XUIInput : XUIObject, IXUIInput +{ + protected override void OnAwake() + { + base.OnAwake(); + m_uiInput = GetComponent(); + if (null == m_uiInput) + { + Debug.LogError("null == m_uiInput"); + } + } + + public void selected(bool value) + { + m_uiInput.isSelected = value; + } + public string GetText() + { + if (null != m_uiInput) + { + return m_uiInput.value; + } + return ""; + } + + public void SetText(string strText) + { + if (null != m_uiInput) + { + m_uiInput.value = strText; + } + } + + + public void SetDefault(string strText) + { + if(null != m_uiInput) + { + m_uiInput.defaultText = strText; + } + } + + public string GetDefault() + { + if (null != m_uiInput) + { + return m_uiInput.defaultText; + } + + return ""; + } + + public void RegisterKeyTriggeredEventHandler(InputKeyTriggeredEventHandler eventHandler) + { + //UIEventListener.Get(this.gameObject).onKey = OnKeyHehe; + EventDelegate.Add(m_uiInput.onKeyTriggered, OnKeyTriggered); + + m_keyTriggerEventHandler = eventHandler; + } + + public void OnKeyTriggered() + { + if (m_keyTriggerEventHandler != null) + m_keyTriggerEventHandler(this, UIInput.current.recentKey); + } + + public void RegisterSubmitEventHandler(InputSubmitEventHandler eventHandler) + { + //UIEventListener.Get(this.gameObject).onKey = OnKeyHehe; + EventDelegate.Add(m_uiInput.onSubmit, OnSubmit); + + m_submitEventHandler = eventHandler; + } + + public void OnSubmit() + { + if (m_submitEventHandler != null) + m_submitEventHandler(this); + } + + public void RegisterChangeEventHandler(InputChangeEventHandler eventHandler) + { + EventDelegate.Add(m_uiInput.onChange, OnChange); + + m_changeEventHandler = eventHandler; + } + + public void OnChange() + { + if(m_changeEventHandler != null) + m_changeEventHandler(this); + } + + public void SetCharacterLimit(int num) + { + m_uiInput.characterLimit = num; + } + UIInput m_uiInput = null; + InputKeyTriggeredEventHandler m_keyTriggerEventHandler; + InputSubmitEventHandler m_submitEventHandler; + InputChangeEventHandler m_changeEventHandler; +} + -- cgit v1.1-26-g67d0