scripts
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEngine.Experimental.UIElements
|
||||
{
|
||||
// Token: 0x0200032A RID: 810
|
||||
internal class IMKeyboardTextField : IMTextField
|
||||
{
|
||||
// Token: 0x060032FD RID: 13053 RVA: 0x0004ED34 File Offset: 0x0004CF34
|
||||
public override bool OnGUI(Event evt)
|
||||
{
|
||||
base.SyncTextEditor();
|
||||
this.m_Changed = false;
|
||||
bool flag = false;
|
||||
switch (evt.type)
|
||||
{
|
||||
case EventType.MouseDown:
|
||||
flag = this.DoMouseDown(new MouseEventArgs(evt.mousePosition, evt.clickCount, evt.modifiers));
|
||||
break;
|
||||
case EventType.MouseUp:
|
||||
flag = this.DoMouseUp(new MouseEventArgs(evt.mousePosition, evt.clickCount, evt.modifiers));
|
||||
break;
|
||||
case EventType.MouseDrag:
|
||||
flag = this.DoMouseDrag(new MouseEventArgs(evt.mousePosition, evt.clickCount, evt.modifiers));
|
||||
break;
|
||||
case EventType.KeyDown:
|
||||
flag = this.DoKeyDown(new KeyboardEventArgs(evt.character, evt.keyCode, evt.modifiers));
|
||||
break;
|
||||
case EventType.Repaint:
|
||||
this.DoRepaint(new StylePainter(evt.mousePosition));
|
||||
break;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
evt.Use();
|
||||
}
|
||||
if (GUIUtility.keyboardControl == base.id)
|
||||
{
|
||||
GUIUtility.textFieldInput = true;
|
||||
}
|
||||
if (this.m_Changed)
|
||||
{
|
||||
GUI.changed = true;
|
||||
base.text = base.editor.text;
|
||||
if (base.maxLength >= 0 && base.text.Length > base.maxLength)
|
||||
{
|
||||
base.text = base.text.Substring(0, base.maxLength);
|
||||
}
|
||||
evt.Use();
|
||||
}
|
||||
base.editor.UpdateScrollOffsetIfNeeded(evt);
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060032FE RID: 13054 RVA: 0x0004EEC4 File Offset: 0x0004D0C4
|
||||
internal override void DoRepaint(IStylePainter args)
|
||||
{
|
||||
if (GUIUtility.keyboardControl != base.id)
|
||||
{
|
||||
base.style.Draw(base.position, GUIContent.Temp(base.text), base.id, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.editor.DrawCursor(base.text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060032FF RID: 13055 RVA: 0x0004EF20 File Offset: 0x0004D120
|
||||
protected override bool DoMouseDown(MouseEventArgs args)
|
||||
{
|
||||
bool flag;
|
||||
if (base.position.Contains(args.mousePosition))
|
||||
{
|
||||
GUIUtility.hotControl = base.id;
|
||||
GUIUtility.keyboardControl = base.id;
|
||||
base.editor.m_HasFocus = true;
|
||||
base.editor.MoveCursorToPosition(args.mousePosition);
|
||||
if (args.clickCount == 2 && GUI.skin.settings.doubleClickSelectsWord)
|
||||
{
|
||||
base.editor.SelectCurrentWord();
|
||||
base.editor.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
|
||||
base.editor.MouseDragSelectsWholeWords(true);
|
||||
}
|
||||
else if (args.clickCount == 3 && GUI.skin.settings.tripleClickSelectsLine)
|
||||
{
|
||||
base.editor.SelectCurrentParagraph();
|
||||
base.editor.MouseDragSelectsWholeWords(true);
|
||||
base.editor.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06003300 RID: 13056 RVA: 0x0004F020 File Offset: 0x0004D220
|
||||
protected override bool DoMouseUp(MouseEventArgs args)
|
||||
{
|
||||
bool flag;
|
||||
if (GUIUtility.hotControl == base.id)
|
||||
{
|
||||
base.editor.MouseDragSelectsWholeWords(false);
|
||||
GUIUtility.hotControl = 0;
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06003301 RID: 13057 RVA: 0x0004F060 File Offset: 0x0004D260
|
||||
protected override bool DoMouseDrag(MouseEventArgs args)
|
||||
{
|
||||
bool flag;
|
||||
if (GUIUtility.hotControl == base.id)
|
||||
{
|
||||
if (args.shift)
|
||||
{
|
||||
base.editor.MoveCursorToPosition(args.mousePosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.editor.SelectToPosition(args.mousePosition);
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06003302 RID: 13058 RVA: 0x0004F0C4 File Offset: 0x0004D2C4
|
||||
protected override bool DoKeyDown(KeyboardEventArgs args)
|
||||
{
|
||||
bool flag;
|
||||
if (GUIUtility.keyboardControl != base.id)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else if (base.editor.HandleKeyEvent(args.ToEvent()))
|
||||
{
|
||||
this.m_Changed = true;
|
||||
base.text = base.editor.text;
|
||||
flag = true;
|
||||
}
|
||||
else if (args.keyCode == KeyCode.Tab || args.character == '\t')
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
char character = args.character;
|
||||
if (character == '\n' && !base.multiline && !args.alt)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Font font = base.style.font;
|
||||
if (font == null)
|
||||
{
|
||||
font = GUI.skin.font;
|
||||
}
|
||||
if (font.HasCharacter(character) || character == '\n')
|
||||
{
|
||||
base.editor.Insert(character);
|
||||
this.m_Changed = true;
|
||||
flag = character == '\n';
|
||||
}
|
||||
else if (character == '\0')
|
||||
{
|
||||
if (Input.compositionString.Length > 0)
|
||||
{
|
||||
base.editor.ReplaceSelection("");
|
||||
this.m_Changed = true;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x04000A6C RID: 2668
|
||||
private bool m_Changed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user