FairyGUI.InputTextField.ReplaceText C# (CSharp) Method

ReplaceText() public method

public ReplaceText ( string value ) : void
value string
return void
        public void ReplaceText(string value)
        {
            if (value == textField.text)
                return;

            value = ValidateInput(value);

            if (value.Length > maxLength)
                value = value.Substring(0, maxLength);

            this.text = value;
            textField.Redraw();
            onChanged.Call();
        }

Usage Example

示例#1
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());
                    }
                }
            }
        }
All Usage Examples Of FairyGUI.InputTextField::ReplaceText