1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 17:52:56 +08:00

Allow deselecting any selection in the editor using the Back binding (escape key)

This commit is contained in:
Dean Herbert 2023-05-24 19:24:14 +09:00
parent 9869e815ce
commit b14b1072c2

View File

@ -16,6 +16,7 @@ using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Edit;
using osuTK;
using osuTK.Input;
@ -26,7 +27,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// A container which provides a "blueprint" display of items.
/// Includes selection and manipulation support via a <see cref="Components.SelectionHandler{T}"/>.
/// </summary>
public abstract partial class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>
public abstract partial class BlueprintContainer<T> : CompositeDrawable, IKeyBindingHandler<PlatformAction>, IKeyBindingHandler<GlobalAction>
where T : class
{
protected DragBox DragBox { get; private set; }
@ -279,6 +280,30 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;
switch (e.Action)
{
case GlobalAction.Back:
if (SelectedItems.Count > 0)
{
DeselectAll();
return true;
}
break;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
#region Blueprint Addition/Removal
protected virtual void AddBlueprintFor(T item)