Use PlatformAction.Delete instead of Delete key

This commit is contained in:
smoogipoo
2019-11-05 13:26:44 +09:00
parent 08bd811326
commit c8beb5296f
2 changed files with 16 additions and 12 deletions

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose; using osu.Game.Screens.Edit.Compose;
@ -15,7 +16,7 @@ using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{ {
public class PathControlPointVisualiser : CompositeDrawable public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler<PlatformAction>
{ {
public Action<Vector2[]> ControlPointsChanged; public Action<Vector2[]> ControlPointsChanged;
@ -84,11 +85,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
} }
} }
protected override bool OnKeyDown(KeyDownEvent e) public bool OnPressed(PlatformAction action)
{ {
switch (e.Key) switch (action.ActionMethod)
{ {
case Key.Delete: case PlatformActionMethod.Delete:
var newControlPoints = new List<Vector2>(); var newControlPoints = new List<Vector2>();
foreach (var piece in Pieces) foreach (var piece in Pieces)
@ -127,5 +128,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return false; return false;
} }
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
} }
} }

View File

@ -8,6 +8,8 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -22,7 +24,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary> /// <summary>
/// A component which outlines <see cref="DrawableHitObject"/>s and handles movement of selections. /// A component which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
/// </summary> /// </summary>
public class SelectionHandler : CompositeDrawable public class SelectionHandler : CompositeDrawable, IKeyBindingHandler<PlatformAction>
{ {
public const float BORDER_RADIUS = 2; public const float BORDER_RADIUS = 2;
@ -72,22 +74,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
} }
protected override bool OnKeyDown(KeyDownEvent e) public bool OnPressed(PlatformAction action)
{ {
if (e.Repeat) switch (action.ActionMethod)
return base.OnKeyDown(e);
switch (e.Key)
{ {
case Key.Delete: case PlatformActionMethod.Delete:
foreach (var h in selectedBlueprints.ToList()) foreach (var h in selectedBlueprints.ToList())
placementHandler.Delete(h.DrawableObject.HitObject); placementHandler.Delete(h.DrawableObject.HitObject);
return true; return true;
} }
return base.OnKeyDown(e); return false;
} }
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
#endregion #endregion
#region Selection Handling #region Selection Handling