黄学彪
2020-09-18 c7df85937f73fb347ee0b19e9c052d2d00a6df6c
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Base/TextInputBase.cs
old mode 100644 new mode 100755
@@ -45,6 +45,10 @@
        /// </summary>
        public Action FinishInputEvent = null;
        /// <summary>
        /// 值改变事件(受MaxByte属性限制)
        /// </summary>
        public Action<string> TextChangedEvent = null;
        /// <summary>
        /// 指定该输入框是否为不可省略(默认为false)
        /// </summary>
        public bool MustInput = false;
@@ -258,12 +262,13 @@
        private void TxtCode_TextChangedEvent(object sender, string value)
        {
            var byteData = Encoding.UTF8.GetBytes(value);
            var newValue = value;
            //如果输入的值,已经大于指定的byte数,则截取
            if (byteData.Length > this.m_MaxByte)
            {
                //截取指定的byte字节
                var newValue = Encoding.UTF8.GetString(byteData, 0, this.m_MaxByte);
                newValue = Encoding.UTF8.GetString(byteData, 0, this.m_MaxByte);
                //最后一位不要,因为截取的最后一位可能是乱码
                newValue = newValue.Substring(0, newValue.Length - 1);
                //拼接上它的下一位,然后检测
@@ -274,11 +279,12 @@
                    newValue = checkValue;
                }
                this.Text = newValue;
#if Android
                //将光标至于最后
#if Android
                this.SetSelectionEnd();
#endif
            }
            this.TextChangedEvent?.Invoke(newValue);
        }
        #endregion
@@ -355,6 +361,7 @@
        public override void RemoveFromParent()
        {
            this.FinishInputEvent = null;
            this.TextChangedEvent = null;
            if (this.Parent != null)
            {
                base.RemoveFromParent();