Fix manual input manager test scenes not matching game input hierarchy

Fix popover using on key down

Fix popover not expiring when using global action
This commit is contained in:
Joseph Madamba 2023-01-10 14:05:08 -08:00
parent c2dd822e4a
commit 776b60f3b3
2 changed files with 17 additions and 5 deletions

View File

@ -5,6 +5,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
@ -14,6 +15,7 @@
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK; using osuTK;
using osuTK.Input;
namespace osu.Game.Graphics.UserInterfaceV2 namespace osu.Game.Graphics.UserInterfaceV2
{ {
@ -58,6 +60,14 @@ protected override void PopOut()
this.FadeOut(fade_duration, Easing.OutQuint); this.FadeOut(fade_duration, Easing.OutQuint);
} }
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Key == Key.Escape)
return false; // disable the framework-level handling of escape key for conformity (we use GlobalAction.Back).
return base.OnKeyDown(e);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
if (e.Repeat) if (e.Repeat)
@ -68,7 +78,7 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
if (e.Action == GlobalAction.Back) if (e.Action == GlobalAction.Back)
{ {
Hide(); this.HidePopover();
return true; return true;
} }

View File

@ -46,21 +46,23 @@ protected OsuManualInputManagerTestScene()
{ {
var mainContent = content = new Container { RelativeSizeAxes = Axes.Both }; var mainContent = content = new Container { RelativeSizeAxes = Axes.Both };
var inputContainer = new Container { RelativeSizeAxes = Axes.Both };
if (DisplayCursorForManualInput) if (DisplayCursorForManualInput)
{ {
var cursorDisplay = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both }; var cursorDisplay = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both };
cursorDisplay.Add(new OsuTooltipContainer(cursorDisplay.MenuCursor) cursorDisplay.Add(content = new OsuTooltipContainer(cursorDisplay.MenuCursor)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = mainContent
}); });
mainContent = cursorDisplay; inputContainer.Add(cursorDisplay);
mainContent = inputContainer;
} }
if (CreateNestedActionContainer) if (CreateNestedActionContainer)
mainContent = new GlobalActionContainer(null).WithChild(mainContent); inputContainer.Add(new GlobalActionContainer(null));
base.Content.AddRange(new Drawable[] base.Content.AddRange(new Drawable[]
{ {