Example #1
0
        /// <summary>
        /// Handles keyboard events. Called from Input subsystems.
        /// </summary>
        /// <returns>True if handled.</returns>
        public bool Input_Key(GwenMappedKey key, bool down)
        {
            if (IsHidden || IsCollapsed)
            {
                return(false);
            }
            if (key <= GwenMappedKey.Invalid)
            {
                return(false);
            }
            if (key >= GwenMappedKey.Count)
            {
                return(false);
            }

            return(InputHandler.OnKeyEvent(this, key, down));
        }
        public bool ProcessKeyDown(KeyboardKeyEventArgs eventArgs)
        {
            char ch = TranslateChar(eventArgs.Key);

            if (InputHandler.DoSpecialKeys(canvas, ch))
            {
                return(false);
            }

            GwenMappedKey iKey = TranslateKeyCode(eventArgs.Key);

            if (iKey == GwenMappedKey.Invalid)
            {
                return(false);
            }

            return(canvas.Input_Key(iKey, true));
        }
Example #3
0
        /// <summary>
        /// Key handler.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        /// <param name="key">Key.</param>
        /// <param name="down">True if the key is down.</param>
        /// <returns>True if handled.</returns>
        public static bool OnKeyEvent(ControlBase canvas, GwenMappedKey key, bool down)
        {
            if (null == KeyboardFocus)
            {
                return(false);
            }
            if (KeyboardFocus.GetCanvas() != canvas)
            {
                return(false);
            }
            if (!KeyboardFocus.IsVisible)
            {
                return(false);
            }

            int iKey = (int)key;

            if (down)
            {
                if (!m_KeyData.KeyState[iKey])
                {
                    m_KeyData.KeyState[iKey]   = true;
                    m_KeyData.NextRepeat[iKey] = Platform.GwenPlatform.GetTimeInSeconds() + KeyRepeatDelay;
                    m_KeyData.Target           = KeyboardFocus;

                    return(KeyboardFocus.InputKeyPressed(key));
                }
            }
            else
            {
                if (m_KeyData.KeyState[iKey])
                {
                    m_KeyData.KeyState[iKey] = false;

                    // BUG BUG. This causes shift left arrow in textboxes
                    // to not work. What is disabling it here breaking?
                    //m_KeyData.Target = NULL;

                    return(KeyboardFocus.InputKeyPressed(key, false));
                }
            }

            return(false);
        }
        public bool ProcessKeyUp(KeyboardKeyEventArgs eventArgs)
        {
            GwenMappedKey key = TranslateKeyCode(eventArgs.Key);

            return(canvas.Input_Key(key, false));
        }
Example #5
0
 /// <summary>
 /// Checks if the given key is pressed.
 /// </summary>
 /// <param name="key">Key to check.</param>
 /// <returns>True if the key is down.</returns>
 public static bool IsKeyDown(GwenMappedKey key)
 {
     return(m_KeyData.KeyState[(int)key]);
 }