/// <summary> /// Whether the handler fires for a specific event /// </summary> /// <param Name="e">The event to test</param> /// <returns>Whether it fires</returns> public override bool DoesAcceptEvent(PInputEventArgs e) { //If either the user presses escape, or the interface will accept the event, accept the event if ((Interface.Accepts(e) || (e.IsKeyEvent && e.KeyCode == Keys.Escape)) && base.DoesAcceptEvent(e)) { e.Handled = true; return(true); } return(false); }
/// <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); } }