//////////////// /// @private public void SetText(string text) { var strBldr = new StringBuilder(text); if (this.OnPreChange != null) { this.OnPreChange.Invoke(strBldr); } text = strBldr.ToString(); if (text.Length > this.MaxLength) { text = text.Substring(0, this.MaxLength); } this.Text = text; this.CursorPos = text.Length; this.DisplayText = UITextInputAreaPanel.GetFittedText(text, this.CursorPos, this.GetInnerDimensions().Width); }
//////////////// /// <summary> /// Manually sets the input text, accommodating cursor position. /// </summary> /// <param name="text">New text.</param> public void SetText(string text) { var strBldr = new StringBuilder(text); if (!this.OnPreTextChange?.Invoke(strBldr) ?? false) { return; } text = strBldr.ToString(); if (text.Length > this.MaxLength) { text = text.Substring(0, this.MaxLength); } this.Text = text; this.CursorPos = text.Length; // TODO: Allow cursor moving this.DisplayText = UITextInputAreaPanel.GetFittedText(text, this.CursorPos, this.GetInnerDimensions().Width); }