Example #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.Keyboard info)
        {
            if (!UseGlobalKeyboardInput)
            {
                KeyboardState.Update(Global.GameTimeUpdate);
                info = KeyboardState;
            }

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

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

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

                if (canTab)
                {
                    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);
        }