Exemplo n.º 1
0
        /// <summary>
        /// Controls the behavior of the textbox relative to users actions and input
        /// </summary>
        public override void Update()
        {
            base.Update();

            if (isActive && !isDisabled)
            {
                OldTextInput = CurrentTextInput;

                if ((Input.Instance.KeyDown(Key.LControl) || Input.Instance.KeyDown(Key.RControl)) && Input.Instance.KeyPressed(Key.V))
                {
                    Input.Instance.KeyString = CurrentTextInput + PasteText();
                    TextDisplay.String       = GetSubstring();
                }

                switch (textBoxType)
                {
                case TextBoxType.NORMAL:
                    CurrentTextInput = GetNormalString(Input.Instance.KeyString);
                    break;

                case TextBoxType.NUMERICAL:
                    CurrentTextInput = GetNumericalString(Input.Instance.KeyString);
                    break;

                case TextBoxType.PASSWORD:
                    CurrentTextInput = GetPasswordString(Input.Instance.KeyString);
                    break;

                case TextBoxType.EMAIL:
                    CurrentTextInput = GetEmailString(Input.Instance.KeyString);
                    break;

                case TextBoxType.NUMERICALDECI:
                    CurrentTextInput = GetNumericalDeciString(Input.Instance.KeyString);
                    break;
                }

                SetSubstringIndex();

                if (CurrentTextInput.Length > MaxCharacters)
                {
                    CurrentTextInput         = CurrentTextInput.Substring(0, MaxCharacters);
                    Input.Instance.KeyString = CurrentTextInput;
                }

                if (Timer % 30 >= 15)
                {
                    TextDisplay.String = GetSubstring();
                    showBlinker        = true;
                }
                else
                {
                    TextDisplay.String = GetSubstring();
                    showBlinker        = false;
                }
            }
            else
            {
                Input.Instance.KeyString = CurrentTextInput;
            }

            if (OldTextInput != CurrentTextInput)
            {
                OnTextChangeEvent.Invoke(this, null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Controls the behavior of the textbox relative to users actions and input
        /// </summary>
        public override void Update()
        {
            base.Update();

            if (isActive)
            {
                OldTextInput = CurrentTextInput;

                switch (textBoxType)
                {
                case TextBoxType.NORMAL:
                    CurrentTextInput = GetNormalString(Input.Instance.KeyString);
                    break;

                case TextBoxType.NUMERICAL:
                    CurrentTextInput = GetNumericalString(Input.Instance.KeyString);
                    break;

                case TextBoxType.PASSWORD:
                    CurrentTextInput = GetPasswordString(Input.Instance.KeyString);
                    break;

                case TextBoxType.EMAIL:
                    CurrentTextInput = GetEmailString(Input.Instance.KeyString);
                    break;

                case TextBoxType.NUMERICALDECI:
                    CurrentTextInput = GetNumericalDeciString(Input.Instance.KeyString);
                    break;
                }

                if (CurrentTextInput.Length > MaxCharacters)
                {
                    CurrentTextInput         = CurrentTextInput.Substring(0, MaxCharacters);
                    Input.Instance.KeyString = CurrentTextInput;
                }

                if (CurrentTextInput.Length < MaxCharacters)
                {
                    if (Timer % 30 >= 15)
                    {
                        text.String = CurrentTextInput + "|";
                    }
                    else
                    {
                        text.String = CurrentTextInput;
                    }
                }
                else
                {
                    text.String = CurrentTextInput;
                }
            }
            else
            {
                Input.Instance.KeyString = CurrentTextInput;
            }

            if (OldTextInput != CurrentTextInput)
            {
                OnTextChangeEvent.Invoke(this, null);
            }
        }