MonoGameUi.Textbox.OnKeyTextPress C# (CSharp) Method

OnKeyTextPress() protected method

protected OnKeyTextPress ( KeyTextEventArgs args ) : void
args KeyTextEventArgs
return void
        protected override void OnKeyTextPress(KeyTextEventArgs args)
        {
            // Ignorieren, wenn kein Fokus
            if (Focused != TreeState.Active) return;

            // Steuerzeichen ignorieren
            if (args.Character == '\b' || args.Character == '\t' || args.Character == '\n' || args.Character == '\r')
                return;

            // Strg-Kombinationen (A, X, C, V) ignorieren
            if (args.Character == '\u0001' ||
                args.Character == '\u0003' ||
                args.Character == '\u0016' ||
                args.Character == '\u0018')
                return;

            //Escape ignorieren
            if (args.Character == '\u001b')
                return;

            if (SelectionStart != CursorPosition)
            {
                int from = Math.Min(SelectionStart, CursorPosition);
                int to = Math.Max(SelectionStart, CursorPosition);
                Text = Text.Substring(0, from) + Text.Substring(to);
                CursorPosition = from;
                SelectionStart = from;
            }

            Text = Text.Substring(0, CursorPosition) + args.Character + Text.Substring(CursorPosition);
            CursorPosition++;
            SelectionStart++;
            args.Handled = true;
        }