Files
2026-06-04 11:42:34 +02:00

235 lines
7.1 KiB
C#

using System;
using UnityEngine.Experimental.UIElements.StyleSheets;
namespace UnityEngine.Experimental.UIElements
{
// Token: 0x02000351 RID: 849
public class TextField : VisualElement
{
// Token: 0x060033EE RID: 13294 RVA: 0x0005287C File Offset: 0x00050A7C
public TextField()
: this(-1, false, false, '\0')
{
}
// Token: 0x060033EF RID: 13295 RVA: 0x0005288C File Offset: 0x00050A8C
public TextField(int maxLength, bool multiline, bool isPasswordField, char maskChar)
{
this.maxLength = maxLength;
this.multiline = multiline;
this.isPasswordField = isPasswordField;
this.maskChar = maskChar;
if (this.touchScreenTextField)
{
this.editor = new TouchScreenTextEditor(this);
}
else
{
this.doubleClickSelectsWord = true;
this.tripleClickSelectsLine = true;
this.editor = new KeyboardTextEditor(this);
}
base.AddManipulator(this.editor);
}
// Token: 0x17000BD5 RID: 3029
// (get) Token: 0x060033F0 RID: 13296 RVA: 0x00052904 File Offset: 0x00050B04
// (set) Token: 0x060033F1 RID: 13297 RVA: 0x00052920 File Offset: 0x00050B20
public bool multiline
{
get
{
return this.m_Multiline;
}
set
{
this.m_Multiline = value;
if (!value)
{
base.text = base.text.Replace("\n", "");
}
}
}
// Token: 0x17000BD6 RID: 3030
// (get) Token: 0x060033F2 RID: 13298 RVA: 0x0005294C File Offset: 0x00050B4C
// (set) Token: 0x060033F3 RID: 13299 RVA: 0x00052968 File Offset: 0x00050B68
public bool isPasswordField
{
get
{
return this.m_IsPasswordField;
}
set
{
this.m_IsPasswordField = value;
if (value)
{
this.multiline = false;
}
}
}
// Token: 0x17000BD7 RID: 3031
// (get) Token: 0x060033F4 RID: 13300 RVA: 0x00052980 File Offset: 0x00050B80
// (set) Token: 0x060033F5 RID: 13301 RVA: 0x0005299C File Offset: 0x00050B9C
public char maskChar { get; set; }
// Token: 0x17000BD8 RID: 3032
// (get) Token: 0x060033F6 RID: 13302 RVA: 0x000529A8 File Offset: 0x00050BA8
// (set) Token: 0x060033F7 RID: 13303 RVA: 0x000529C4 File Offset: 0x00050BC4
public bool doubleClickSelectsWord { get; set; }
// Token: 0x17000BD9 RID: 3033
// (get) Token: 0x060033F8 RID: 13304 RVA: 0x000529D0 File Offset: 0x00050BD0
// (set) Token: 0x060033F9 RID: 13305 RVA: 0x000529EC File Offset: 0x00050BEC
public bool tripleClickSelectsLine { get; set; }
// Token: 0x17000BDA RID: 3034
// (get) Token: 0x060033FA RID: 13306 RVA: 0x000529F8 File Offset: 0x00050BF8
// (set) Token: 0x060033FB RID: 13307 RVA: 0x00052A14 File Offset: 0x00050C14
public int maxLength { get; set; }
// Token: 0x17000BDB RID: 3035
// (get) Token: 0x060033FC RID: 13308 RVA: 0x00052A20 File Offset: 0x00050C20
private bool touchScreenTextField
{
get
{
return TouchScreenKeyboard.isSupported;
}
}
// Token: 0x17000BDC RID: 3036
// (get) Token: 0x060033FD RID: 13309 RVA: 0x00052A3C File Offset: 0x00050C3C
internal GUIStyle style
{
get
{
GUIStyle guistyle;
if ((guistyle = this.m_DrawGUIStyle) == null)
{
guistyle = (this.m_DrawGUIStyle = new GUIStyle());
}
return guistyle;
}
}
// Token: 0x17000BDD RID: 3037
// (get) Token: 0x060033FE RID: 13310 RVA: 0x00052A6C File Offset: 0x00050C6C
public bool hasFocus
{
get
{
return base.elementPanel != null && base.elementPanel.focusedElement == this;
}
}
// Token: 0x17000BDE RID: 3038
// (get) Token: 0x060033FF RID: 13311 RVA: 0x00052AA0 File Offset: 0x00050CA0
// (set) Token: 0x06003400 RID: 13312 RVA: 0x00052ABC File Offset: 0x00050CBC
public TextEditor editor { get; protected set; }
// Token: 0x06003401 RID: 13313 RVA: 0x00052AC8 File Offset: 0x00050CC8
public override void OnStylesResolved(ICustomStyles styles)
{
base.OnStylesResolved(styles);
this.m_Styles.WriteToGUIStyle(this.style);
}
// Token: 0x06003402 RID: 13314 RVA: 0x00052AE4 File Offset: 0x00050CE4
internal override void DoRepaint(IStylePainter painter)
{
if (this.touchScreenTextField)
{
TouchScreenTextEditor touchScreenTextEditor = this.editor as TouchScreenTextEditor;
if (touchScreenTextEditor != null && touchScreenTextEditor.keyboardOnScreen != null)
{
base.text = touchScreenTextEditor.keyboardOnScreen.text;
if (this.editor.maxLength >= 0 && base.text != null && base.text.Length > this.editor.maxLength)
{
base.text = base.text.Substring(0, this.editor.maxLength);
}
if (touchScreenTextEditor.keyboardOnScreen.done)
{
touchScreenTextEditor.keyboardOnScreen = null;
GUI.changed = true;
}
}
string text = base.text;
if (touchScreenTextEditor != null && !string.IsNullOrEmpty(touchScreenTextEditor.secureText))
{
text = "".PadRight(touchScreenTextEditor.secureText.Length, this.maskChar);
}
this.style.Draw(base.position, GUIContent.Temp(text), 0, false);
}
else if (this.isPasswordField)
{
string text2 = "".PadRight(base.text.Length, this.maskChar);
if (!this.hasFocus)
{
this.style.Draw(base.position, GUIContent.Temp(text2), 0, false);
}
else
{
this.DrawCursor(text2);
}
}
else if (!this.hasFocus)
{
this.style.Draw(base.position, GUIContent.Temp(base.text), 0, false);
}
else
{
this.DrawCursor(base.text);
}
}
// Token: 0x06003403 RID: 13315 RVA: 0x00052C90 File Offset: 0x00050E90
private void DrawCursor(string newText)
{
KeyboardTextEditor keyboardTextEditor = this.editor as KeyboardTextEditor;
if (keyboardTextEditor != null)
{
keyboardTextEditor.PreDrawCursor(newText);
int cursorIndex = keyboardTextEditor.cursorIndex;
int selectIndex = keyboardTextEditor.selectIndex;
Rect localPosition = keyboardTextEditor.localPosition;
Vector2 scrollOffset = keyboardTextEditor.scrollOffset;
Vector2 contentOffset = this.style.contentOffset;
this.style.contentOffset -= scrollOffset;
this.style.Internal_clipOffset = scrollOffset;
Input.compositionCursorPos = keyboardTextEditor.graphicalCursorPos - scrollOffset + new Vector2(localPosition.x, localPosition.y + this.style.lineHeight);
GUIContent guicontent = new GUIContent(keyboardTextEditor.text);
if (!string.IsNullOrEmpty(Input.compositionString))
{
this.style.DrawWithTextSelection(base.position, guicontent, this.HasCapture(), this.hasFocus, cursorIndex, cursorIndex + Input.compositionString.Length, true);
}
else
{
this.style.DrawWithTextSelection(base.position, guicontent, this.HasCapture(), this.hasFocus, cursorIndex, selectIndex, false);
}
if (keyboardTextEditor.altCursorPosition != -1)
{
this.style.DrawCursor(base.position, guicontent, 0, keyboardTextEditor.altCursorPosition);
}
this.style.contentOffset = contentOffset;
this.style.Internal_clipOffset = Vector2.zero;
keyboardTextEditor.PostDrawCursor();
}
}
// Token: 0x04000AEF RID: 2799
private bool m_Multiline;
// Token: 0x04000AF0 RID: 2800
private bool m_IsPasswordField;
// Token: 0x04000AF5 RID: 2805
internal const int kMaxLengthNone = -1;
// Token: 0x04000AF6 RID: 2806
private GUIStyle m_DrawGUIStyle;
}
}