コード例 #1
0
        /// <summary>
        /// Processes the keyboard for the console.
        /// </summary>
        /// <param name="info">Keyboard information sent by the engine.</param>
        public override bool ProcessKeyboard(Input.KeyboardInfo info)
        {
            info = KeyboardState;

            if (updateKeyboardState)
            {
                info.ProcessKeys(Engine.GameTimeUpdate);
            }

            var handlerResult = KeyboardHandler == null ? false : KeyboardHandler(this, info);

            if (!handlerResult && this.CanUseKeyboard)
            {
                bool canTab = true;

                if (FocusedControl != null)
                {
                    canTab = FocusedControl.TabStop;
                }

                if (canTab)
                {
                    if (
#if SFML
                        ((info.IsKeyDown(Keys.LShift) ||
                          info.IsKeyDown(Keys.RShift)) ||

                         info.IsKeyReleased(Keys.LShift) ||
                         info.IsKeyReleased(Keys.RShift))
#elif MONOGAME
                        ((info.IsKeyDown(Keys.LeftShift) ||
                          info.IsKeyDown(Keys.RightShift)) ||

                         info.IsKeyReleased(Keys.LeftShift) ||
                         info.IsKeyReleased(Keys.RightShift))
#endif
                        &&
                        info.IsKeyReleased(Keys.Tab))
                    {
                        // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                        TabPreviousControl();
                        return(true);
                    }
                    else if (info.IsKeyReleased(Keys.Tab))
                    {
                        // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                        TabNextControl();
                        return(false);
                    }
                }

                if (FocusedControl != null && FocusedControl.IsEnabled && FocusedControl.CanUseKeyboard)
                {
                    return(FocusedControl.ProcessKeyboard(info));
                }
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Processes the keyboard for the console.
        /// </summary>
        /// <param name="info">Keyboard information sent by the engine.</param>
        public override bool ProcessKeyboard(Input.KeyboardInfo info)
        {
            var handlerResult = KeyboardHandler == null ? false : KeyboardHandler(this, info);

            if (!handlerResult && this.CanUseKeyboard)
            {
                bool canTab = true;

                if (FocusedControl != null)
                {
                    canTab = FocusedControl.TabStop;
                }

                if (canTab)
                {
                    if (((info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) ||
                          info.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift)) ||

                         info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.LeftShift) ||
                         info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.RightShift))

                        &&
                        info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Tab))
                    {
                        // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                        TabPreviousControl();
                        return(true);
                    }
                    else if (info.IsKeyReleased(Microsoft.Xna.Framework.Input.Keys.Tab))
                    {
                        // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                        TabNextControl();
                        return(false);
                    }
                }

                if (FocusedControl != null && FocusedControl.IsEnabled && FocusedControl.CanUseKeyboard)
                {
                    return(FocusedControl.ProcessKeyboard(info));
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Processes the keyboard for the console.
        /// </summary>
        /// <param name="info">Keyboard information sent by the engine.</param>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (!UseGlobalKeyboardInput)
            {
                KeyboardState.Update(Global.GameTimeUpdate);
                info = KeyboardState;
            }

            var handlerResult = KeyboardHandler == null ? false : KeyboardHandler(this, info);

            if (!handlerResult && this.UseKeyboard)
            {
                if (
                    ((info.IsKeyDown(Keys.LeftShift) ||
                      info.IsKeyDown(Keys.RightShift)) ||

                     info.IsKeyReleased(Keys.LeftShift) ||
                     info.IsKeyReleased(Keys.RightShift))

                    &&
                    info.IsKeyReleased(Keys.Tab))
                {
                    // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                    TabPreviousControl();
                    return(true);
                }
                else if (info.IsKeyReleased(Keys.Tab))
                {
                    // TODO: Handle tab by changing focused control unless existing control doesn't support tab
                    TabNextControl();
                    return(false);
                }

                if (FocusedControl != null && FocusedControl.IsEnabled && FocusedControl.UseKeyboard)
                {
                    return(FocusedControl.ProcessKeyboard(info));
                }
            }

            return(false);
        }