예제 #1
0
        public bool ControlKeyPress(KeyInfo key)
        {
            bool handled = false;

            // send to this control
            IInputHandler handler = this as IInputHandler;

            if (handler != null)
            {
                if (key.Down)
                {
                    handled = handler.KeyDown(key);
                }
                else
                {
                    handled = handler.KeyUp(key);
                }
            }

            // send to child controls
            if (!handled)
            {
                foreach (Control control in mControls)
                {
                    handled = control.ControlKeyPress(key);
                }
            }

            return(handled);
        }
예제 #2
0
        public void ScreenKeyPress(KeyInfo key)
        {
            bool handled;

            if (mFocus == null)
            {
                // broadcast to controls
                handled = ControlKeyPress(key);
            }
            else
            {
                // just send to the focus control
                if (key.Down)
                {
                    handled = mFocus.KeyDown(key);
                }
                else
                {
                    handled = mFocus.KeyUp(key);
                }
            }

            // send to the screen if nothing else handled it
            if (!handled)
            {
                IInputHandler handler = this as IInputHandler;

                if (handler != null)
                {
                    if (key.Down)
                    {
                        handler.KeyDown(key);
                    }
                    else
                    {
                        handler.KeyUp(key);
                    }
                }
            }
        }