Exemplo n.º 1
0
 public void Init(int index, GameFormula formula)
 {
     Index            = index;
     Formula          = formula;
     _inputField.text = formula.KFloats[index].ToString();
     _inputField.ForceLabelUpdate();
 }
 public void Toggle()
 {
     show              = !show;
     eyeIcon.text      = show ? "" : "";
     input.contentType = show ? TMP_InputField.ContentType.Standard : TMP_InputField.ContentType.Password;
     input.ForceLabelUpdate();
 }
 private void PreventCaretOverflow()
 {
     if (isHighlighterCaret && TMPInputField.caretPosition >= TMPInputField.text.Length)
     {
         TMPInputField.caretPosition = TMPInputField.text.Length - 1;
         TMPInputField.ForceLabelUpdate();
     }
 }
Exemplo n.º 4
0
        void OnEnable()
        {
            if (inputText == null)
            {
                return;
            }

            inputText.ForceLabelUpdate();
            UpdateState();
        }
Exemplo n.º 5
0
        private IEnumerator ReturnCaretPosition(int index)
        {
            yield return(null);

            if (inputField != null)
            {
                inputField.caretPosition           = index;
                inputField.selectionAnchorPosition = index;
                inputField.selectionFocusPosition  = index;
                inputField.ForceLabelUpdate();
            }
        }
 void OnToggleVisiblity(Toggle toggle)
 {
     if (toggle.isOn)
     {
         eyeToggleImg.sprite   = toggleSprites[0];
         contactIF.contentType = TMP_InputField.ContentType.Password;
     }
     else
     {
         eyeToggleImg.sprite   = toggleSprites[1];
         contactIF.contentType = TMP_InputField.ContentType.IntegerNumber;
     }
     contactIF.ForceLabelUpdate();
     eyeToggleImg.SetNativeSize();
 }
Exemplo n.º 7
0
 public void OnClick()
 {
     _isOn = !_isOn;
     if (_isOn)
     {
         _image.sprite            = _onSprite;
         _passwordField.inputType = TMP_InputField.InputType.Standard;
     }
     else
     {
         _image.sprite            = _offSprite;
         _passwordField.inputType = TMP_InputField.InputType.Password;
     }
     _passwordField.ForceLabelUpdate();
     onChange?.Invoke(_isOn);
 }
Exemplo n.º 8
0
    public void swapSprite()
    {
        try
        {
            if (swapSpriteSprite.gameObject.activeSelf)
            {
                swapSpriteSprite.gameObject.SetActive(false);
                passField.contentType = TMP_InputField.ContentType.Standard;
            }
            else
            {
                swapSpriteSprite.gameObject.SetActive(true);
                passField.contentType = TMP_InputField.ContentType.Password;
            }


            passField.ForceLabelUpdate();
        } catch { };
    }
Exemplo n.º 9
0
        public void RemoveLastSymbol()
        {
            int pos         = _inputField.caretPosition < _inputField.selectionAnchorPosition ? _inputField.caretPosition : _inputField.selectionAnchorPosition;
            int removeCount = 0;


            if (pos > 0)
            {
                int length   = _inputField.text.Length;
                int caretPos = _inputField.caretPosition;

                removeCount = Mathf.Abs(_inputField.caretPosition - _inputField.selectionAnchorPosition);
                removeCount = Mathf.Max(1, removeCount);

                pos = removeCount > 1 ? pos : pos - 1;

                _inputField.text = _inputField.text.Remove(pos, removeCount);

                if (removeCount == 1)
                {
                    if (caretPos < length)
                    {
                        _inputField.caretPosition--;
                    }
                }
                else
                {
                    if (_inputField.caretPosition > _inputField.selectionAnchorPosition)
                    {
                        _inputField.caretPosition = _inputField.selectionAnchorPosition;
                    }
                }

                _inputField.selectionAnchorPosition = _inputField.caretPosition;

                _inputField.ForceLabelUpdate();
            }

            onButtonClicked?.Invoke();
        }
Exemplo n.º 10
0
    void TypeFieldHandler()
    {
        if (typeField.text.ToLower() == "p")
        {
            typeField.text = "Place";

            typeField.caretPosition           = typeField.text.Length;
            typeField.selectionAnchorPosition = 5;
            typeField.ForceLabelUpdate();
        }
        else if (typeField.text.ToLower() == "c")
        {
            typeField.text = "Character";
        }
        else if (typeField.text.ToLower() == "i")
        {
            typeField.text = "Item";
        }


        UpdateFeedbackText();
    }
 public void SetMessage(string text)
 {
     messageArea.text = text;
     messageArea.ForceLabelUpdate();
 }
Exemplo n.º 12
0
        private void AutoIndentCaret(bool isClosingToken = false)
        {
            // Check for new line
            if (Input.GetKeyDown(KeyCode.Return) == true)
            {
                // Update line column and indent positions
                UpdateCurrentLineColumnIndent();

                // Build indent string
                string indent = string.Empty;

                // Make sure we have some text
                if (inputField.caretPosition < inputField.text.Length)
                {
                    // Check for tabs before caret
                    int beforeIndentCount = 0;
                    int caretIndentCount  = 0;
                    for (int i = inputField.caretPosition; i >= 0; i--)
                    {
                        // Check for tab characters
                        if (inputField.text[i] == '\t')
                        {
                            beforeIndentCount++;
                        }

                        // Check for previous line or spaces
                        if (inputField.text[i] == '\n' || (languageTheme.autoIndent.autoIndentMode == AutoIndent.IndentMode.AutoTabContextual && inputField.text[i] != ' '))
                        {
                            if (i != inputField.caretPosition)
                            {
                                break;
                            }
                        }
                    }

                    if (languageTheme.autoIndent.autoIndentMode == AutoIndent.IndentMode.AutoTabContextual)
                    {
                        // Take into account any previous tab characters
                        caretIndentCount = currentIndent - caretIndentCount;
                    }
                    else
                    {
                        caretIndentCount = beforeIndentCount;
                    }

                    indent = GetAutoIndentTab(caretIndentCount);

                    //int length = 0;

                    //for(int i = inputField.caretPosition + 1; i < inputField.text.Length; i++, length++)
                    //{
                    //    if (inputField.text[i] == '\n')
                    //        break;
                    //}

                    //int caret = 0;
                    //string formatted = languageTheme.autoIndent.GetAutoIndentedFormattedString(inputField.text.Substring(inputField.caretPosition + 1, length), currentIndent, out caret);

                    //inputField.text = inputField.text.Remove(inputField.caretPosition + 1, length);
                    //inputField.text = inputField.text.Insert(inputField.caretPosition + 1, formatted);

                    //inputField.stringPosition = inputField.stringPosition + caret;
                    //return;
                }


                if (indent.Length > 0)
                {
                    // Get caret position
                    inputField.text = inputField.text.Insert(inputField.caretPosition + 1, indent);

                    // Move to the end of the new line
                    inputField.stringPosition = inputField.stringPosition + indent.Length;
                }

                //if (languageTheme.autoIndent.autoIndentMode == AutoIndent.IndentMode.AutoTabContextual)
                //{
                // Check for closing bracket
                bool immediateClosing = false;
                int  closingOffset    = -1;

                for (int i = inputField.caretPosition + 1; i < inputField.text.Length; i++)
                {
                    if (inputField.text[i] == languageTheme.autoIndent.indentDecreaseCharacter)
                    {
                        // Set the closing flag
                        immediateClosing = true;
                        closingOffset    = i - (inputField.caretPosition + 1);
                        break;
                    }

                    // Check for any other character
                    if (char.IsWhiteSpace(inputField.text[i]) == false || inputField.text[i] == '\n')
                    {
                        break;
                    }
                }

                if (immediateClosing == true)
                {
                    // Remove unnecessary white space
                    inputField.text = inputField.text.Remove(inputField.caretPosition + 1, closingOffset);

                    string localIndent = (string.IsNullOrEmpty(indent) == true) ? string.Empty : indent.Remove(0, 1);


                    // Insert new line
                    inputField.text = inputField.text.Insert(inputField.caretPosition + 1, GetAutoIndentTab(currentIndent) + "\n" + localIndent);

                    //inputField.stringPosition -= 1;

                    if (string.IsNullOrEmpty(localIndent) == false)
                    {
                        //inputField.stringPosition -= localIndent.Length;
                    }


                    // Update line column and indent positions
                    UpdateCurrentLineColumnIndent();
                }
            }
            //}

            // Check for closing token
            if (isClosingToken == true)
            {
                if (inputField.caretPosition > 0)
                {
                    // Check for tab before caret
                    if (inputField.text[inputField.caretPosition - 1] == '\t')
                    {
                        // Remove 1 tab because we have received a closing token
                        inputField.text = inputField.text.Remove(inputField.caretPosition - 1, 1);

                        inputField.stringPosition = inputField.stringPosition - 1;
                    }
                }
            }

            inputText.text = inputField.text;
            inputText.SetText(inputField.text, true);
            inputText.Rebuild(CanvasUpdate.Prelayout);
            inputField.ForceLabelUpdate();
            inputField.Rebuild(CanvasUpdate.Prelayout);
            Refresh(true);
            delayedRefresh = true;
        }
Exemplo n.º 13
0
 public void GetRandomName()
 {
     CompanyInput.text = NameList.getRandomName();
     CompanyInput.ForceLabelUpdate();
 }
Exemplo n.º 14
0
 private void SetInputField(string classStr, string methodStr, string args)
 {
     inputField.text          = (classStr + "." + methodStr + "(" + args + ")");
     inputField.caretPosition = inputField.text.Length;
     inputField.ForceLabelUpdate();
 }