diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/UICommon/XUIInput.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/UICommon/XUIInput.cs')
-rw-r--r-- | Client/Assets/Scripts/UICommon/XUIInput.cs | 106 |
1 files changed, 106 insertions, 0 deletions
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<UIInput>();
+ 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;
+}
+
|