internal TextInputBase() { isReadOnly = false; focusable = true; AddToClassList(inputUssClassName); m_Text = string.Empty; name = TextField.textInputUssName; requireMeasureFunction = true; editorEngine = new TextEditorEngine(OnDetectFocusChange, OnCursorIndexChange); if (touchScreenTextField) { editorEventHandler = new TouchScreenTextEditorEventHandler(editorEngine, this); } else { // TODO: Default values should come from GUI.skin.settings doubleClickSelectsWord = true; tripleClickSelectsLine = true; editorEventHandler = new KeyboardTextEditorEventHandler(editorEngine, this); } // Make the editor style unique across all textfields editorEngine.style = new GUIStyle(editorEngine.style); RegisterCallback <CustomStyleResolvedEvent>(OnCustomStyleResolved); RegisterCallback <AttachToPanelEvent>(OnAttachToPanel); this.generateVisualContent += OnGenerateVisualContent; }
internal void OnGenerateVisualContent(MeshGenerationContext mgc) { string text = this.text; bool isPasswordField = this.isPasswordField; if (isPasswordField) { text = "".PadRight(this.text.Length, this.maskChar); } bool touchScreenTextField = this.touchScreenTextField; if (touchScreenTextField) { TouchScreenTextEditorEventHandler touchScreenTextEditorEventHandler = this.editorEventHandler as TouchScreenTextEditorEventHandler; bool flag = touchScreenTextEditorEventHandler != null; if (flag) { mgc.Text(MeshGenerationContextUtils.TextParams.MakeStyleBased(this, text), this.m_TextHandle, base.scaledPixelsPerPoint); } } else { bool flag2 = !this.hasFocus; if (flag2) { mgc.Text(MeshGenerationContextUtils.TextParams.MakeStyleBased(this, text), this.m_TextHandle, base.scaledPixelsPerPoint); } else { this.DrawWithTextSelectionAndCursor(mgc, text, base.scaledPixelsPerPoint); } } }