接收用户输入的文本控件。因为支持直接输入表情,所以从RichTextField派生。
Inheritance: RichTextField
示例#1
0
        protected override void CreateDisplayObject()
        {
            inputTextField        = new InputTextField();
            inputTextField.gOwner = this;
            displayObject         = inputTextField;

            _textField = inputTextField.textField;
        }
 public void StartRecord(InputTextField textField)
 {
     _undoBuffer.Clear();
     _redoBuffer.Clear();
     _textField    = textField;
     _lock         = false;
     _currentText  = textField.text;
     _changedFrame = 0;
 }
示例#3
0
        void HandleTextInput()
        {
            InputTextField textField = (InputTextField)_focused;

            if (!textField.editable)
            {
                return;
            }

            textField.CheckComposition();
        }
示例#4
0
 void OnFocusRemoved(EventContext context)
 {
     if (context.sender == _focused)
     {
         if (_focused is InputTextField)
         {
             _lastInput = null;
         }
         this.focus = null;
     }
 }
示例#5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="textField"></param>
 /// <param name="value"></param>
 public static void OnCopy(InputTextField textField, string value)
 {
     TextEditor te = new TextEditor();
     #if UNITY_5_3_OR_NEWER
     te.text = value;
     #else
     te.content = new GUIContent(value);
     #endif
     te.OnFocus();
     te.Copy();
 }
        public void StopRecord(InputTextField textField)
        {
            if (_textField != textField)
            {
                return;
            }

            _undoBuffer.Clear();
            _redoBuffer.Clear();
            _textField   = null;
            _currentText = null;
        }
示例#7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="textField"></param>
 public static void OnPaste(InputTextField textField)
 {
     TextEditor te = new TextEditor();
     te.Paste();
     #if UNITY_5_3_OR_NEWER
     string value = te.text;
     #else
     string value = te.content.text;
     #endif
     if (!string.IsNullOrEmpty(value))
         textField.ReplaceSelection(value);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="textField"></param>
        /// <param name="value"></param>
        public static void OnCopy(InputTextField textField, string value)
        {
            TextEditor te = new TextEditor();

#if UNITY_5_3_OR_NEWER
            te.text = value;
#else
            te.content = new GUIContent(value);
#endif
            te.OnFocus();
            te.Copy();
        }
示例#9
0
        void HandleTextInput()
        {
            InputTextField textField = (InputTextField)_focused;

            if (!textField.editable)
            {
                return;
            }

            if (_keyboard != null)
            {
                if (textField.keyboardInput)
                {
                    string s = _keyboard.GetInput();
                    if (s != null)
                    {
                        if (_keyboard.supportsCaret)
                        {
                            textField.ReplaceSelection(s);
                        }
                        else
                        {
                            textField.ReplaceText(s);
                        }
                    }

                    if (_keyboard.done)
                    {
                        this.focus = null;
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(Input.inputString))
                {
                    StringBuilder sb  = new StringBuilder();
                    int           len = Input.inputString.Length;
                    for (int i = 0; i < len; ++i)
                    {
                        char ch = Input.inputString[i];
                        if (ch >= ' ')
                        {
                            sb.Append(ch.ToString());
                        }
                    }
                    if (sb.Length > 0)
                    {
                        textField.ReplaceSelection(sb.ToString());
                    }
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="textField"></param>
        public static void OnPaste(InputTextField textField)
        {
            TextEditor te = new TextEditor();

            te.Paste();
#if UNITY_5_3_OR_NEWER
            string value = te.text;
#else
            string value = te.content.text;
#endif
            if (!string.IsNullOrEmpty(value))
            {
                textField.ReplaceSelection(value);
            }
        }
示例#11
0
    static int get_inputTextField(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.GTextInput     obj = (FairyGUI.GTextInput)o;
            FairyGUI.InputTextField ret = obj.inputTextField;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index inputTextField on a nil value"));
        }
    }
        public void MarkChanged(InputTextField textField)
        {
            if (_textField != textField)
            {
                return;
            }

            if (_lock)
            {
                return;
            }

            string newText = _textField.text;

            if (_currentText == newText)
            {
                return;
            }

            if (_changedFrame != Time.frameCount)
            {
                _changedFrame = Time.frameCount;
                _undoBuffer.Add(_currentText);
                if (_undoBuffer.Count > maxHistoryLength)
                {
                    _undoBuffer.RemoveAt(0);
                }
            }
            else
            {
                int cnt = _undoBuffer.Count;
                if (cnt > 0 && newText == _undoBuffer[cnt - 1])
                {
                    _undoBuffer.RemoveAt(cnt - 1);
                }
            }
            _currentText = newText;
        }
示例#13
0
        void HandleTextInput()
        {
            InputTextField textField = (InputTextField)_focused;

            if (!textField.editable)
            {
                return;
            }

            if (keyboardInput)
            {
                if (textField.keyboardInput && _keyboard != null)
                {
                    string s = _keyboard.GetInput();
                    if (s != null)
                    {
                        if (_keyboard.supportsCaret)
                        {
                            textField.ReplaceSelection(s);
                        }
                        else
                        {
                            textField.ReplaceText(s);
                        }
                    }

                    if (_keyboard.done)
                    {
                        this.focus = null;
                    }
                }
            }
            else
            {
                textField.CheckComposition();
            }
        }
示例#14
0
        protected override void CreateDisplayObject()
        {
            inputTextField = new InputTextField();
            inputTextField.gOwner = this;
            displayObject = inputTextField;

            _textField = inputTextField.textField;
        }