/// <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);
            };
        }
        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);
                }
            };
        }
示例#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;
        }
示例#4
0
 protected virtual void OnKeyTextPress(KeyTextEventArgs args)
 {
 }
示例#5
0
        internal void InternalKeyTextPress(KeyTextEventArgs args)
        {
            // Children first (Order by Z-Order)
            foreach (var child in Children.InZOrder())
            {
                child.InternalKeyTextPress(args);
                if (args.Handled)
                    break;
            }

            // Bubble up
            if (!args.Handled)
            {
                OnKeyTextPress(args);
                if (KeyTextPress != null)
                    KeyTextPress(this, args);
            }
        }
示例#6
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;
        }