From 9fa44bc13574817c0b0de56e1ee84e93745ac67c Mon Sep 17 00:00:00 2001 From: kongehund <63306696+kongehund@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:19:11 +0100 Subject: [PATCH 1/3] Close object context menu on tool change --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 4b64548f9c73..57966c38bc4a 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -531,6 +531,9 @@ private void toolSelected(CompositionTool tool) if (!(tool is SelectTool)) EditorBeatmap.SelectedHitObjects.Clear(); + + // Prevent object context menu from staying open. + GetContainingFocusManager()?.ChangeFocus(null); } #endregion From 5bdeac4435d421f9c678b4a5528e47eebeff1165 Mon Sep 17 00:00:00 2001 From: kongehund <63306696+kongehund@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:00:03 +0100 Subject: [PATCH 2/3] Add test --- .../Editor/TestSceneContextMenuClose.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs new file mode 100644 index 000000000000..628e9a4cacc4 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs @@ -0,0 +1,40 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets.UI; +using osuTK.Input; + +namespace osu.Game.Rulesets.Osu.Tests.Editor +{ + public partial class TestSceneContextMenuClose : TestSceneOsuEditor + { + private ContextMenuContainer contextMenuContainer + => Editor.ChildrenOfType().First(); + + + [Test] + public void TestToolChangeClosesMenu() + { + Playfield playfield = null!; + + AddStep("select circle placement tool", () => InputManager.Key(Key.Number2)); + AddStep("move mouse to top left of playfield", () => + { + playfield = this.ChildrenOfType().Single(); + var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4; + InputManager.MoveMouseTo(location); + }); + AddStep("place circle", () => InputManager.Click(MouseButton.Left)); + AddStep("right click circle", () => InputManager.Click(MouseButton.Right)); + AddUntilStep("context menu is visible", () => contextMenuContainer.ChildrenOfType().Single().State == MenuState.Open); + AddStep("select slider placement tool", () => InputManager.Key(Key.Number3)); + AddUntilStep("context menu is not visible", () => contextMenuContainer.ChildrenOfType().Single().State == MenuState.Closed); + } + } +} From 8c17999f6c2526b78a722e05ad74f3286418fc16 Mon Sep 17 00:00:00 2001 From: kongehund <63306696+kongehund@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:03:41 +0100 Subject: [PATCH 3/3] Remove extra newline --- osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs index 628e9a4cacc4..c04297490193 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs @@ -17,7 +17,6 @@ public partial class TestSceneContextMenuClose : TestSceneOsuEditor private ContextMenuContainer contextMenuContainer => Editor.ChildrenOfType().First(); - [Test] public void TestToolChangeClosesMenu() {