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

right click on unselected object shows context menu

This commit is contained in:
Jason Won 2021-10-26 14:52:15 -04:00
parent ec6e28bca6
commit f64fa65fd5
2 changed files with 33 additions and 3 deletions

View File

@ -42,6 +42,30 @@ namespace osu.Game.Tests.Visual.Editing
});
}
[Test]
public void TestSelectAndShowContextMenu()
{
var addedObject = new HitCircle { StartTime = 100, Position = new Vector2(100, 100) };
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
moveMouseToObject(() => addedObject);
AddStep("right click", () => InputManager.Click(MouseButton.Right));
AddAssert("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObject);
AddStep("delete from context menu", () =>
{
var pos = blueprintContainer.SelectionBlueprints
.First(s => s.Item == addedObject)
.ChildrenOfType<HitCirclePiece>()
.First();
InputManager.MoveMouseTo(pos, new Vector2(50, 120));
InputManager.Click(MouseButton.Left);
});
AddAssert("no hitobjects in beatmap", () => EditorBeatmap.HitObjects.Count == 0);
}
[Test]
public void TestNudgeSelection()
{

View File

@ -108,11 +108,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnMouseDown(MouseDownEvent e)
{
bool selectionPerformed = performMouseDownActions(e);
// even if a selection didn't occur, a drag event may still move the selection.
bool movementPossible = prepareSelectionMovement();
return selectionPerformed || (e.Button == MouseButton.Left && movementPossible);
// check if selection has occurred
if (selectionPerformed)
{
// propagate right click to show context menu on selection
return e.Button != MouseButton.Right;
}
// even if a selection didn't occur, a drag event may still move the selection.
return e.Button == MouseButton.Left && movementPossible;
}
protected SelectionBlueprint<T> ClickedBlueprint { get; private set; }