1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 18:27:26 +08: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:
Drew DeVault 2017-01-31 19:00:54 -05:00
parent 637a99e8d0
commit 4597a765b8
3 changed files with 14 additions and 11 deletions

View File

@ -18,6 +18,7 @@ namespace osu.Game.Screens.Select
public string Search => searchTextBox.Text;
public SortMode Sort { get; private set; } = SortMode.Title;
public Action Exit;
private SearchTextBox searchTextBox;
@ -50,10 +51,8 @@ namespace osu.Game.Screens.Select
}
};
searchTextBox.OnChange += (sender, text) =>
{
FilterChanged?.Invoke();
};
searchTextBox.OnChange += (sender, text) => FilterChanged?.Invoke();
searchTextBox.Exit = () => Exit?.Invoke();
}
public void Deactivate()

View File

@ -146,6 +146,7 @@ namespace osu.Game.Screens.Select
Position = wedged_container_start_position,
RelativeSizeAxes = Axes.X,
FilterChanged = filterChanged,
Exit = () => Exit(),
},
beatmapInfoWedge = new BeatmapInfoWedge
{

View File

@ -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);
}