示例#1
0
        //////////////////////////////////////////////////////////////////////////////

        #region Event handler

        public override bool HandleEvent(Event evt)
        {
            if (eventHandlers.HandleEvent(evt))
            {
                return(true);
            }

            if (evt.code == Event.KEY)
            {
                if (mFocusedView != null)
                {
                    if (mFocusedView.HandleEvent(evt))
                    {
                        return(true);
                    }
                }

                KeyEvent keyEvent = evt as KeyEvent;
                if (keyEvent.state == KeyState.Pressed)
                {
                    if (keyEvent.IsKeyPressed(KeyCode.Escape) ||
                        keyEvent.IsKeyPressed(KeyCode.GP_B) || keyEvent.IsKeyPressed(KeyCode.GP_Back))
                    {
                        if (OnCancelPressed(keyEvent.arg))
                        {
                            return(true);
                        }
                    }

                    if (keyEvent.IsKeyPressed(KeyCode.Enter) ||
                        keyEvent.IsKeyPressed(KeyCode.GP_A) || keyEvent.IsKeyPressed(KeyCode.GP_Start))
                    {
                        if (OnConfirmPressed(keyEvent.arg))
                        {
                            return(true);
                        }
                    }
                }

                switch (keyEvent.state)
                {
                case KeyState.Pressed:
                case KeyState.Repeated:
                    return(TryMoveFocus(keyEvent.arg.key));
                }
            }

            return(base.HandleEvent(evt));
        }