mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Fix escape key to exit PlaySongSelect
This is less than ideal but is the least disruptive solution. The InputManager itself holds Escape keypresses from getting to anything else if something is focused.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
@ -15,6 +16,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
|
||||
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
|
||||
public Action Exit;
|
||||
public bool GrabFocus = false;
|
||||
|
||||
private SpriteText placeholder;
|
||||
@ -60,11 +62,6 @@ namespace osu.Game.Screens.Select
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (GrabFocus && !HasFocus && IsVisible)
|
||||
@ -72,10 +69,16 @@ namespace osu.Game.Screens.Select
|
||||
base.Update();
|
||||
}
|
||||
|
||||
protected override void OnFocusLost(InputState state)
|
||||
{
|
||||
if (state.Keyboard.Keys.Any(key => key == Key.Escape))
|
||||
Exit?.Invoke();
|
||||
base.OnFocusLost(state);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Key == Key.Left || args.Key == Key.Right
|
||||
|| args.Key == Key.Enter || args.Key == Key.Escape)
|
||||
if (args.Key == Key.Left || args.Key == Key.Right || args.Key == Key.Enter)
|
||||
return false;
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user