コード例 #1
0
ファイル: TextBox.cs プロジェクト: jorolf/osu-framework
        private Drawable addCharacter(char c)
        {
            if (char.IsControl(c))
            {
                return(null);
            }

            if (selectionLength > 0)
            {
                removeCharacterOrSelection();
            }

            if (text.Length + 1 > LengthLimit)
            {
                if (Background.Alpha > 0)
                {
                    Background.FlashColour(Color4.Red, 200);
                }
                else
                {
                    TextFlow.FlashColour(Color4.Red, 200);
                }
                return(null);
            }

            Drawable ch = AddCharacterToFlow(c);

            text           = text.Insert(selectionLeft, c.ToString());
            selectionStart = selectionEnd = selectionLeft + 1;

            cursorAndLayout.Invalidate();

            return(ch);
        }
コード例 #2
0
        private Drawable addCharacter(char c)
        {
            if (char.IsControl(c))
            {
                return(null);
            }

            if (selectionLength > 0)
            {
                removeCharacterOrSelection();
            }

            if (text.Length + 1 > LengthLimit)
            {
                if (background.Alpha > 0)
                {
                    background.FlashColour(Color4.Red, 200);
                }
                else
                {
                    textFlow.FlashColour(Color4.Red, 200);
                }
                return(null);
            }

            Drawable ch = AddCharacterToFlow(c);

            ch.Position = new Vector2(0, SpaceWidth);
            ch.MoveToY(0, 200, EasingTypes.OutExpo);

            text           = text.Insert(selectionLeft, c.ToString());
            selectionStart = selectionEnd = selectionLeft + 1;

            cursorAndLayout.Invalidate();

            return(ch);
        }