1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:07:33 +08:00

Modify FooterButton to implement IKeyBindingHandler for responding to hotkeys

This commit is contained in:
Jack Boswell (boswelja) 2020-06-04 15:21:13 +12:00
parent 55953b9e85
commit 782fddb6f1

View File

@ -12,10 +12,12 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Framework.Input.Bindings;
namespace osu.Game.Screens.Select
{
public class FooterButton : OsuClickableContainer
public class FooterButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
{
public const float SHEAR_WIDTH = 7.5f;
@ -117,7 +119,7 @@ namespace osu.Game.Screens.Select
public Action Hovered;
public Action HoverLost;
public Key? Hotkey;
public GlobalAction? Hotkey;
protected override void UpdateAfterChildren()
{
@ -167,15 +169,19 @@ namespace osu.Game.Screens.Select
return base.OnClick(e);
}
protected override bool OnKeyDown(KeyDownEvent e)
public virtual bool OnPressed(GlobalAction action)
{
if (!e.Repeat && e.Key == Hotkey)
if (action == Hotkey)
{
Click();
return true;
}
return false;
}
return base.OnKeyDown(e);
public virtual void OnReleased(GlobalAction action)
{
}
}
}