コード例 #1
0
 void ChangeApplyed(object obj)
 {
     ChangePoint(textInfo);
     ThreadMission.InvokeToMain((o) => {
         InputCaret.ChangeCaret(textInfo);
     }, null);
 }
コード例 #2
0
        internal override void OnDragEnd(UserAction action)
        {
            long r = action.EventTicks - pressTime;

            if (r <= ClickTime)
            {
                float x = action.CanPosition.x;
                float y = action.CanPosition.y;
                x -= RawPosition.x;
                x *= x;
                y -= RawPosition.y;
                y *= y;
                x += y;
                if (x < ClickArea)
                {
                    return;
                }
            }
            textInfo.endSelect = GetPressIndex(textInfo, this, action, ref textInfo.endDock);
            Selected();
            if (OnSelectEnd != null)
            {
                OnSelectEnd(this, action);
            }
            InputCaret.ChangeCaret(textInfo);
        }
コード例 #3
0
 protected override void OnDrag(UserAction action)
 {
     a++;
     if (a < 2)
     {
         return;
     }
     a = 0;
     if (Pressed)
     {
         if (TextCom != null)
         {
             if (entry)
             {
                 if (action.Motion != Vector2.zero)
                 {
                     textInfo.CaretStyle = 2;
                     int end = textInfo.endSelect;
                     textInfo.endSelect = GetPressIndex(textInfo, this, action, ref textInfo.endDock);
                     if (end != textInfo.endSelect)
                     {
                         Selected();
                         if (OnSelectChanged != null)
                         {
                             OnSelectChanged(this, action);
                         }
                         InputCaret.ChangeCaret(textInfo);
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
        internal override void Update()
        {
            switch (Style)
            {
            case 0:
                InputCaret.Hide();
                break;

            case 2:
                if (ShowChanged)
                {
                    InputCaret.Active();
                    ShowChanged = false;
                    List <HVertex> hs   = new List <HVertex>();
                    List <int>     tris = new List <int>();
                    GetSelectArea(SelectionColor, tris, hs);
                    InputCaret.ChangeCaret(hs.ToArray(), tris.ToArray());
                }
                break;
            }
            if (Focus)
            {
                if (Keyboard.GetKeyDown(KeyCode.C) & Keyboard.GetKey(KeyCode.LeftControl))
                {
                    GUIUtility.systemCopyBuffer = GetSelectString();
                }
                if (Keyboard.GetKeyDown(KeyCode.A) & Keyboard.GetKey(KeyCode.LeftControl))
                {
                    SelectAll();
                    ShowChanged = true;
                }
            }
        }
コード例 #5
0
        void TextChanged()
        {
            var text = TextCom;

            text.text = textInfo.text;
            SetShowText();
            string str = textInfo.buffer.FilterString;

            Populate(text, str);
            var g = text.cachedTextGenerator;

            UIVertex[] vert = new UIVertex[g.verts.Count];
            for (int i = 0; i < vert.Length; i++)
            {
                vert[i] = g.verts[i];
            }
            textInfo.vertex = vert;
            UILineInfo[] us = new UILineInfo[g.lines.Count];
            for (int i = 0; i < us.Length; i++)
            {
                us[i] = g.lines[i];
            }
            textInfo.lines          = us;
            textInfo.characterCount = g.characterCount;
            textInfo.visibleCount   = g.characterCountVisible;
            ChangePoint(textInfo);
            InputCaret.ChangeCaret(textInfo);
        }
コード例 #6
0
        void Update()
        {
            var te = TextCom;

            if (te.Context != null)
            {
                if (textChanged)
                {
                    textInfo.fontSize = TextCom.data.fontSize;
                    textChanged       = false;
                    GetPreferredHeight(TextCom, textInfo);
                    textInfo.StartLine += textInfo.LineChange;
                    textInfo.EndLine   += textInfo.LineChange;
                    lineChanged         = true;
                    var lines = textInfo.fullLines;
                    if (lines != null)
                    {
                        int i     = lines.Length - 1;
                        int start = textInfo.startSelect;
                        for (; i >= 0; i--)
                        {
                            int t = lines[i].startCharIdx;
                            if (t <= start)
                            {
                                textInfo.lineIndex = start - t;
                                break;
                            }
                        }
                    }
                }
                if (lineChanged)
                {
                    lineChanged = false;
                    FilterPopulate(TextCom, textInfo);
                    TextCom.text             =
                        TextCom.Context.text = textInfo.ShowString.FullString;
                }
                if (selectChanged)
                {
                    textInfo.fontSize   = TextCom.data.fontSize;
                    textInfo.caretColor = PointColor;
                    textInfo.areaColor  = SelectionColor;
                    selectChanged       = false;
                    if (textInfo.CaretStyle == 2)
                    {
                        FilterChoiceArea(TextCom, textInfo);
                    }
                    else
                    {
                        ChangePoint(textInfo, this);
                    }
                    InputCaret.ChangeCaret(textInfo);
                }
            }
        }
コード例 #7
0
 public override void OnMouseDown(UserAction action)
 {
     Focus = true;
     if (TextCom != null)
     {
         EndPress = StartPress = GetPressIndex(action, Vector2.zero);
         InputCaret.SetParent(TextCom.transform);
         InputCaret.Active();
         ShowChanged = true;
     }
     base.OnMouseDown(action);
 }
コード例 #8
0
        internal override void OnLostFocus(UserAction action)
        {
            if (this == InputEvent)
            {
                if (InputEvent.OnDone != null)
                {
                    InputEvent.OnDone(InputEvent);
                }
                InputEvent = null;
            }
            Editing = false;
            SetShowText();

            InputCaret.Hide();
            Keyboard.EndInput();
        }
コード例 #9
0
 internal override void OnClick(UserAction action)
 {
     if (InputEvent != this)
     {
         InputEvent = this;
         bool pass = InputEvent.contentType == ContentType.Password ? true : false;
         Keyboard.OnInput(Text.FullString, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
         InputCaret.SetParent(Context.transform);
         pressOffset = StartPress.Offset;
         Editing     = true;
     }
     else if (!Keyboard.active)
     {
         bool pass = InputEvent.contentType == ContentType.Password ? true : false;
         Keyboard.OnInput(Text.FullString, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
     }
     Style = 1;
 }
コード例 #10
0
        void OnLostFocus(EventCallBack eventCall, UserAction action)
        {
            TextInput text = eventCall as TextInput;

            if (text == InputEvent)
            {
                if (InputEvent.OnDone != null)
                {
                    InputEvent.OnDone(InputEvent);
                }
                InputEvent = null;
            }
            Editing = false;
            SetShowText();
            ThreadMission.InvokeToMain((o) => {
                Keyboard.EndInput();
                InputCaret.Hide();
            }, null);
        }
コード例 #11
0
        void OnClick(EventCallBack eventCall, UserAction action)
        {
            TextInput input = eventCall as TextInput;

            if (input == null)
            {
                return;
            }
            InputEvent           = input;
            textInfo.startSelect = GetPressIndex(textInfo, this, action, ref textInfo.startDock);
            textInfo.endSelect   = -1;
            textInfo.CaretStyle  = 1;
            ChangePoint(textInfo);
            bool pass = InputEvent.contentType == ContentType.Password ? true : false;

            Keyboard.OnInput(textInfo.text, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
            InputCaret.SetParent(Target);
            InputCaret.ChangeCaret(textInfo);
        }
コード例 #12
0
        void OnClick(EventCallBack eventCall, UserAction action)
        {
            TextInput input = eventCall as TextInput;

            if (input == null)
            {
                return;
            }
            InputEvent           = input;
            textInfo.startSelect = GetPressIndex(textInfo, this, action, ref textInfo.startDock) + textInfo.StartIndex;
            textInfo.endSelect   = -1;
            textInfo.CaretStyle  = 1;
            selectChanged        = true;
            ThreadMission.InvokeToMain((o) => {
                bool pass = InputEvent.contentType == ContentType.Password ? true : false;
                Keyboard.OnInput(textInfo.text, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
                InputCaret.SetParent(Context.Context);
                InputCaret.ChangeCaret(textInfo);
            }, null);
        }
コード例 #13
0
 void SetSelectPoint(int index)
 {
     if (index != 0)
     {
         index += textInfo.startSelect;
         if (index < 0)
         {
             index = 0;
         }
         if (index > textInfo.text.Length)
         {
             index = textInfo.text.Length;
         }
     }
     textInfo.startSelect = index;
     textInfo.endSelect   = -1;
     textInfo.CaretStyle  = 1;
     ChangePoint(textInfo);
     ThreadMission.InvokeToMain((o) => { InputCaret.ChangeCaret(textInfo); }, null);
 }
コード例 #14
0
        void Refresh()
        {
            InputCaret.CaretStyle = Style;
            var te = TextCom;

            if (te != null)
            {
                if (textChanged)
                {
                    textChanged = false;
                    GetPreferredHeight();
                }
                if (lineChanged)
                {
                    lineChanged = false;
                    SetShowText();
                    TextCom.Populate();
                    ShowChanged = true;
                }
                if (Style == 2)
                {
                    if (ShowChanged)
                    {
                        ShowChanged = false;
                        InputCaret.Active();
                        List <HVertex> hs   = new List <HVertex>();
                        List <int>     tris = new List <int>();
                        GetSelectArea(SelectionColor, tris, hs);
                        InputCaret.ChangeCaret(hs.ToArray(), tris.ToArray());
                    }
                }
                else if (ShowChanged)
                {
                    ShowChanged = false;
                    SetShowText();
                }
            }
        }
コード例 #15
0
        public void SetPressPointer()
        {
            if (TextCom == null)
            {
                return;
            }
            int line = StartPress.Row - ShowStart;

            if (line >= 0)
            {
                var ul = TextCom.uILines;
                int c  = ul.Length;
                if (line < c)
                {
                    bool right = false;
                    int  os    = StartPress.Offset;
                    if (lines[StartPress.Row].Count == os)
                    {
                        right = true;
                        os--;
                    }
                    int   index = ul[line].startCharIdx + os;
                    float h     = TextCom.uILines[line].height;
                    var   ch    = TextCom.uIChars[index];
                    float rx    = ch.cursorPos.x - 0.5f;
                    if (right)
                    {
                        rx += ch.charWidth + 1;
                    }
                    float lx = rx - 2f;
                    float ty = ch.cursorPos.y;
                    float dy = ty - h;
                    InputCaret.ChangeCaret(lx, rx, ty, dy, PointColor);
                }
            }
        }
コード例 #16
0
 internal override void OnClick(UserAction action)
 {
     Style = 0;
     InputCaret.Hide();
 }
コード例 #17
0
 public static void Clear()
 {
     InputEvent = null;
     InputCaret.Hide();
 }
コード例 #18
0
 internal override void OnLostFocus(UserAction eventCall)
 {
     Style = 0;
     InputCaret.Hide();
     Focus = false;
 }