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="value"></param> public void InputString(string value) { if (_lastInput != null) { _lastInput.ReplaceSelection(value); } }
/// <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> 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); } }
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(); } }