Пример #1
0
        /// <summary>
        /// Show the interface if it isn't already being shown
        ///
        /// If it is being shown, and the user presses escape, remove it
        /// </summary>
        public override void OnKeyDown(object sender, PInputEventArgs e)
        {
            base.OnKeyDown(sender, e);
            //If the interface isn't shown, and should be
            if (IsPressed == false && Interface.Accepts(e))
            {
                //Clear the text from the last time it was used, and show it to the user
                Interface.Entry.Text = "";
                Camera.AddChild(Interface);

                //Fetch the current keyboard focus to save for later, then shift the keyboard focus to the interface
                if (Page.LastPage != null)
                {
                    KeyFocus = Page.LastPage.ToPickPath();
                }
                else
                {
                    KeyFocus = Camera.ToPickPath();
                }
                e.InputManager.KeyboardFocus = Interface.Entry.ToPickPath(e.Camera, Interface.Entry.Bounds);

                //Activate the interface
                IsPressed = true;
                Interface.Activate(sender, e);
            }

            //If the user pressed ecape, remove the interface
            else if (e.KeyCode == Keys.Escape)
            {
                RemoveInterface(e);
            }

            //Register the Activate button press, if appropriate
            if (Interface.Accepts(e))
            {
                Interface.RegisterActivateButtonPress(sender, e);
            }
        }