1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Merge pull request #7648 from peppy/keyboard-composition-tools

Allow selecting composition tools using 1-4 keys
This commit is contained in:
Dan Balasescu 2020-01-29 17:29:11 +09:00 committed by GitHub
commit 77b1bf3ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Logging;
using osu.Framework.Threading;
using osu.Framework.Timing;
@ -25,6 +26,7 @@ using osu.Game.Screens.Edit.Components.RadioButtons;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
using Key = osuTK.Input.Key;
namespace osu.Game.Rulesets.Edit
{
@ -148,6 +150,22 @@ namespace osu.Game.Rulesets.Edit
blueprintContainer.SelectionChanged += selectionChanged;
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Key >= Key.Number1 && e.Key <= Key.Number9)
{
var item = toolboxCollection.Items.Skip(e.Key - Key.Number1).FirstOrDefault();
if (item != null)
{
item.Select();
return true;
}
}
return base.OnKeyDown(e);
}
protected override void LoadComplete()
{
base.LoadComplete();