Exemple #1
0
        /// <summary>
        /// Erzeugt eine neue Instanz der Klasse BaseScreenComponent.
        /// </summary>
        /// <param name="game">Die aktuelle Game-Instanz.</param>
        public BaseScreenComponent(Game game)
            : base(game)
        {
            Content = game.Content;

            KeyboardEnabled  = true;
            MouseEnabled     = true;
            GamePadEnabled   = true;
            TouchEnabled     = true;
            DoubleClickDelay = DEFAULTDOUBLECLICKDELAY;

#if !ANDROID
            Game.Window.TextInput += (s, e) =>
            {
                if (Game.IsActive)
                {
                    KeyTextEventArgs args = new KeyTextEventArgs()
                    {
                        Character = e.Character
                    };

                    root.InternalKeyTextPress(args);
                }
            };
#endif

            Game.Window.ClientSizeChanged += (s, e) =>
            {
                if (ClientSizeChanged != null)
                {
                    ClientSizeChanged(s, e);
                }
            };
        }
Exemple #2
0
        /// <summary>
        /// Erzeugt eine neue Instanz der Klasse BaseScreenComponent.
        /// </summary>
        /// <param name="game">Die aktuelle Game-Instanz.</param>
        public BaseScreenComponent(Game game)
            : base(game)
        {
            Content = game.Content;

            Game.Window.TextInput += (s, e) =>
            {
                if (Game.IsActive)
                {
                    KeyTextEventArgs args = new KeyTextEventArgs()
                    {
                        Character = e.Character
                    };

                    root.InternalKeyTextPress(args);
                }
            };

            Game.Window.ClientSizeChanged += (s, e) =>
            {
                if (ClientSizeChanged != null)
                {
                    ClientSizeChanged(s, e);
                }
            };
        }
Exemple #3
0
        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;
        }